Skip to content

Commit 27bbb12

Browse files
author
Ivan Dlugos
committed
generated code - use const constructors
1 parent d84156e commit 27bbb12

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

generator/lib/src/code_chunks.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ class CodeChunks {
194194

195195
String? fbReader;
196196
var readFieldOrNull = () =>
197-
'$fbReader.vTableGetNullable(buffer, rootOffset, ${propertyFlatBuffersvTableOffset(p)})';
197+
'const $fbReader.vTableGetNullable(buffer, rootOffset, ${propertyFlatBuffersvTableOffset(p)})';
198198
var readFieldNonNull = ([String? defaultValue]) =>
199-
'$fbReader.vTableGet(buffer, rootOffset, ${propertyFlatBuffersvTableOffset(p)}, ${defaultValue ?? fieldDefaultValue(p)})';
199+
'const $fbReader.vTableGet(buffer, rootOffset, ${propertyFlatBuffersvTableOffset(p)}, ${defaultValue ?? fieldDefaultValue(p)})';
200200
var readField =
201201
() => p.fieldIsNullable ? readFieldOrNull() : readFieldNonNull();
202202

objectbox/analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ linter:
1919
- prefer_relative_imports
2020
- type_annotate_public_apis
2121
- prefer_initializing_formals
22+
- prefer_const_constructors
23+
- prefer_const_constructors_in_immutables
2224
# - lines_longer_than_80_chars
2325

2426
# exclude standalone packages:

objectbox/test/sync_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void main() {
277277

278278
// Note: wait for the client to finish sending to the server.
279279
// There's currently no other way to recognize this.
280-
sleep(Duration(milliseconds: 100));
280+
sleep(const Duration(milliseconds: 100));
281281
client.close();
282282

283283
final client2 = loggedInClient(env2.store);
@@ -401,7 +401,7 @@ class SyncServer {
401401
} on SocketException catch (e) {
402402
// only retry if "connection refused"
403403
if (e.osError!.errorCode != 111) rethrow;
404-
await Future<void>.delayed(Duration(milliseconds: 1));
404+
await Future<void>.delayed(const Duration(milliseconds: 1));
405405
}
406406
}
407407
httpClient.close(force: true);

objectbox/test/test_env.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bool waitUntil(bool Function() predicate, {Duration timeout = defaultTimeout}) {
3535
final until = DateTime.now().add(timeout);
3636

3737
while (!(success = predicate()) && until.isAfter(DateTime.now())) {
38-
sleep(Duration(milliseconds: 1));
38+
sleep(const Duration(milliseconds: 1));
3939
}
4040
return success;
4141
}

0 commit comments

Comments
 (0)