Skip to content

Commit 3761384

Browse files
author
cgiuliani
committed
feat: make ConfigScope const
1 parent 0a93742 commit 3761384

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

Diff for: configurator/lib/src/writers/configuration_writer.dart

+22-14
Original file line numberDiff line numberDiff line change
@@ -17,72 +17,79 @@ class ConfigWriter extends Writer {
1717
builder
1818
..name = 'Generated$name'
1919
..extend = refer( 'ConfigScope' )
20+
..constructors.add(
21+
Constructor(
22+
(b) {
23+
b.constant = true;
24+
},
25+
),
26+
)
2027
..fields.addAll([
2128
_nameField(),
2229

2330
_mapGetter(
2431
name: 'weight',
25-
returnType: 'int',
26-
assignment: '_Weight().map[\'weight\'] ?? 0',
32+
returnType: 'final int',
33+
assignment: 'const _Weight().map[\'weight\'] ?? 0',
2734
),
2835

2936
_mapGetter(
3037
name: 'flags',
31-
returnType: 'Map<String, bool>',
38+
returnType: 'final Map<String, bool>',
3239
assignment: 'const _Flags().map',
3340
),
3441

3542
_mapGetter(
3643
name: 'images',
37-
returnType: 'Map<String, dynamic>',
44+
returnType: 'final Map<String, dynamic>',
3845
assignment: 'const _Images().map',
3946
),
4047

4148
_mapGetter(
4249
name: 'colors',
43-
returnType: 'Map<String, String>',
50+
returnType: 'final Map<String, String>',
4451
assignment: 'const _Colors().map',
4552
),
4653

4754
_mapGetter(
4855
name: 'sizes',
49-
returnType: 'Map<String, double>',
56+
returnType: 'final Map<String, double>',
5057
assignment: 'const _Sizes().map',
5158
),
5259

5360
_mapGetter(
5461
name: 'padding',
55-
returnType: 'Map<String, double>',
62+
returnType: 'final Map<String, double>',
5663
assignment: 'const _Padding().map',
5764
),
5865

5966
_mapGetter(
6067
name: 'margins',
61-
returnType: 'Map<String, double>',
68+
returnType: 'final Map<String, double>',
6269
assignment: 'const _Margins().map',
6370
),
6471

6572
_mapGetter(
6673
name: 'misc',
67-
returnType: 'Map<String, dynamic>',
74+
returnType: 'final Map<String, dynamic>',
6875
assignment: 'const _Misc().map',
6976
),
7077

7178
_mapGetter(
7279
name: 'textStyles',
73-
returnType: 'Map<String, dynamic>',
80+
returnType: 'final Map<String, dynamic>',
7481
assignment: 'const _TextStyle().map',
7582
),
7683

7784
_mapGetter(
7885
name: 'routes',
79-
returnType: 'Map<int, String>',
86+
returnType: 'final Map<int, String>',
8087
assignment: 'const _Routes().map',
8188
),
8289

8390
_mapGetter(
8491
name: 'translations',
85-
returnType: ' Map<String, Map<String, String>>',
92+
returnType: 'final Map<String, Map<String, String>>',
8693
assignment: () {
8794
Map<String, dynamic> parsed = I18nParser.parse(
8895
strings: strings,
@@ -96,7 +103,7 @@ class ConfigWriter extends Writer {
96103

97104
data = data.replaceAll(r'+$', r'+\$');
98105

99-
return data;
106+
return 'const $data';
100107
}(),
101108
),
102109
]);
@@ -107,9 +114,10 @@ class ConfigWriter extends Writer {
107114
return Field( ( builder ) {
108115
builder
109116
..name = 'name'
117+
..modifier = FieldModifier.final$
110118
..annotations.add( refer( 'override' ) )
111119
..type = refer('String')
112-
..assignment = const Code( '\'__GeneratedScope\'' );
120+
..assignment = Code( '"__Generated$name"' );
113121
});
114122
}
115123

Diff for: configurator/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: configurator
22
description: A new Flutter package project.
3-
version: 0.0.26
3+
version: 0.0.27
44
homepage:
55

66
environment:

Diff for: configurator_flutter/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: configurator_flutter
22
description: A new Flutter package project.
3-
version: 0.0.26
3+
version: 0.0.27
44
homepage:
55

66
environment:
@@ -29,7 +29,7 @@ dependencies:
2929
git:
3030
url: [email protected]:camrongiuliani/configurator.git
3131
path: configurator
32-
ref: 0.0.26
32+
ref: 0.0.27
3333

3434
dev_dependencies:
3535
flutter_test:

0 commit comments

Comments
 (0)