Skip to content

Commit 4f0391a

Browse files
committed
Formatted and fixed lints
1 parent 29536dc commit 4f0391a

File tree

13 files changed

+26
-28
lines changed

13 files changed

+26
-28
lines changed

analysis_options.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,3 @@ linter:
4040
use_super_parameters: true
4141
# jni rules
4242
prefer_const_declarations: true
43-
# native_assets_builder rules
44-
prefer_expression_function_bodies: true

pkgs/ffi/example/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void main() {
1515

1616
// Use the Utf8 helper to encode zero-terminated UTF-8 strings in native
1717
// memory.
18-
final myString = '😎👿💬';
18+
const myString = '😎👿💬';
1919
final charPointer = myString.toNativeUtf8();
2020
print('First byte is: ${charPointer.cast<Uint8>().value}');
2121
print(charPointer.toDartString());

pkgs/ffi/test/allocation_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ void main() async {
2424

2525
test('testPointerAllocateTooLarge', () {
2626
// Try to allocate something that doesn't fit in 64 bit address space.
27-
final maxInt = 9223372036854775807; // 2^63 - 1
27+
const maxInt = 9223372036854775807; // 2^63 - 1
2828
expect(() => calloc<Uint8>(maxInt), throwsA(isA<ArgumentError>()));
2929

3030
// Try to allocate almost the full 64 bit address space.
31-
final maxInt1_8 = 1152921504606846975; // 2^60 -1
31+
const maxInt1_8 = 1152921504606846975; // 2^60 -1
3232
expect(() => calloc<Uint8>(maxInt1_8), throwsA(isA<ArgumentError>()));
3333
});
3434

pkgs/ffi/test/utf16_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:test/test.dart';
99

1010
void main() {
1111
test('toUtf16 ASCII', () {
12-
final start = 'Hello World!\n';
12+
const start = 'Hello World!\n';
1313
final converted = start.toNativeUtf16().cast<Uint16>();
1414
final end = converted.asTypedList(start.codeUnits.length + 1);
1515
final matcher = equals(start.codeUnits.toList()..add(0));
@@ -18,7 +18,7 @@ void main() {
1818
});
1919

2020
test('toUtf16 emoji', () {
21-
final start = '😎';
21+
const start = '😎';
2222
final converted = start.toNativeUtf16().cast();
2323
final length = start.codeUnits.length;
2424
final end = converted.cast<Uint16>().asTypedList(length + 1);
@@ -28,38 +28,38 @@ void main() {
2828
});
2929

3030
test('from Utf16 ASCII', () {
31-
final string = 'Hello World!\n';
31+
const string = 'Hello World!\n';
3232
final utf16Pointer = string.toNativeUtf16();
3333
final stringAgain = utf16Pointer.toDartString();
3434
expect(stringAgain, string);
3535
calloc.free(utf16Pointer);
3636
});
3737

3838
test('from Utf16 emoji', () {
39-
final string = '😎';
39+
const string = '😎';
4040
final utf16Pointer = string.toNativeUtf16();
4141
final stringAgain = utf16Pointer.toDartString();
4242
expect(stringAgain, string);
4343
calloc.free(utf16Pointer);
4444
});
4545

4646
test('zero bytes', () {
47-
final string = 'Hello\x00World!\n';
47+
const string = 'Hello\x00World!\n';
4848
final utf16Pointer = string.toNativeUtf16();
4949
final stringAgain = utf16Pointer.toDartString(length: 13);
5050
expect(stringAgain, string);
5151
calloc.free(utf16Pointer);
5252
});
5353

5454
test('length', () {
55-
final string = 'Hello';
55+
const string = 'Hello';
5656
final utf16Pointer = string.toNativeUtf16();
5757
expect(utf16Pointer.length, 5);
5858
calloc.free(utf16Pointer);
5959
});
6060

6161
test('fromUtf8 with negative length', () {
62-
final string = 'Hello';
62+
const string = 'Hello';
6363
final utf16 = string.toNativeUtf16();
6464
expect(() => utf16.toDartString(length: -1), throwsRangeError);
6565
calloc.free(utf16);

pkgs/ffi/test/utf8_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pointer<Uint8> _bytesFromList(List<int> ints) {
1717

1818
void main() {
1919
test('toUtf8 ASCII', () {
20-
final start = 'Hello World!\n';
20+
const start = 'Hello World!\n';
2121
final converted = start.toNativeUtf8().cast<Uint8>();
2222
final end = converted.asTypedList(start.length + 1);
2323
final matcher = equals(
@@ -36,7 +36,7 @@ void main() {
3636
});
3737

3838
test('toUtf8 emoji', () {
39-
final start = '😎👿💬';
39+
const start = '😎👿💬';
4040
final converted = start.toNativeUtf8().cast<Utf8>();
4141
final length = converted.length;
4242
final end = converted.cast<Uint8>().asTypedList(length + 1);
@@ -100,7 +100,7 @@ void main() {
100100
});
101101

102102
test('length', () {
103-
final string = 'Hello';
103+
const string = 'Hello';
104104
final utf8Pointer = string.toNativeUtf8();
105105
expect(utf8Pointer.length, 5);
106106
calloc.free(utf8Pointer);
@@ -117,7 +117,7 @@ void main() {
117117
});
118118

119119
test('zero terminated', () {
120-
final string = 'Hello';
120+
const string = 'Hello';
121121
final utf8Pointer = string.toNativeUtf8();
122122
final charPointer = utf8Pointer.cast<Char>();
123123
expect(charPointer[utf8Pointer.length], 0);

pkgs/ffigen/lib/src/code_generator/writer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Writer {
192192

193193
/// Finding a unique prefix for Array Helper Classes and store into
194194
/// [_arrayHelperClassPrefix].
195-
final base = 'ArrayHelper';
195+
const base = 'ArrayHelper';
196196
_arrayHelperClassPrefix = base;
197197
var suffixInt = 0;
198198
for (var i = 0; i < allNameSet.length; i++) {

pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void _compoundMembersVisitor(
278278
// Anonymous members are always unnamed. To avoid environment-
279279
// dependent naming issues with the generated code, we explicitly
280280
// use the empty string as spelling.
281-
final spelling = '';
281+
const spelling = '';
282282

283283
parsed.compound.members.add(
284284
CompoundMember(

pkgs/ffigen/lib/src/header_parser/sub_parsers/macro_parser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ late Set<String> _macroVarNames;
167167
/// Creates a temporary file for parsing macros in current directory.
168168
File createFileForMacros() {
169169
final fileNameBase = p.normalize(p.join(strings.tmpDir, 'temp_for_macros'));
170-
final fileExt = 'hpp';
170+
const fileExt = 'hpp';
171171

172172
// Find a filename which doesn't already exist.
173173
var file = File('$fileNameBase.$fileExt');

pkgs/ffigen/test/code_generator_tests/code_generator_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ void main() {
601601
});
602602

603603
test('Adds Native symbol on mismatch', () {
604-
final nativeConfig = const FfiNativeConfig(enabled: true);
604+
const nativeConfig = FfiNativeConfig(enabled: true);
605605
final library = Library(
606606
name: 'init_dylib',
607607
header:

pkgs/ffigen/test/config_tests/compiler_opts_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import '../test_utils.dart';
1313
void main() {
1414
group('compiler_opts_test', () {
1515
test('Compiler Opts', () {
16-
final opts =
16+
const opts =
1717
'''--option value "in double quotes" 'in single quotes' -tab=separated''';
1818
final list = compilerOptsToList(opts);
1919
expect(

0 commit comments

Comments
 (0)