Skip to content

Commit 1f4f6cc

Browse files
authored
fix: Make the builder name compatible with both flutter_gen and flutter_gen_runner (#592)
## What does this change? Fixes #589 🎯 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [x] This change requires a documentation update
1 parent a5f0e4e commit 1f4f6cc

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ You can also configure generate options in the `build.yaml`, it will be read bef
181181
targets:
182182
$default:
183183
builders:
184-
flutter_gen:
184+
flutter_gen_runner: # or flutter_gen
185185
options:
186186
output: lib/build_gen/ # Optional (default: lib/gen/)
187187
line_length: 120 # Optional (default: 80)

packages/command/test/flutter_gen_command_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() {
1414
);
1515
expect(
1616
await process.stdout.next,
17-
equals('$flutterGenVersion Loading ... command${separator}pubspec.yaml'),
17+
equals('$flutterGenVersion Loading ...'),
1818
);
1919
await process.shouldExit(0);
2020
});
@@ -26,7 +26,7 @@ void main() {
2626
);
2727
expect(
2828
await process.stdout.next,
29-
equals('$flutterGenVersion Loading ... command${separator}pubspec.yaml'),
29+
equals('$flutterGenVersion Loading ...'),
3030
);
3131
await process.shouldExit(0);
3232
});

packages/core/lib/settings/config.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ Config loadPubspecConfig(File pubspecFile, {File? buildFile}) {
3737
if (buildFile != null && buildFile.existsSync()) {
3838
final buildContent = buildFile.readAsStringSync();
3939
final rawMap = loadYaml(buildContent) as Map?;
40-
final optionBuildMap = rawMap?['targets']?[r'$default']?['builders']
41-
?['flutter_gen']?['options'];
42-
43-
if (optionBuildMap != null) {
40+
final builders = rawMap?['targets']?[r'$default']?['builders'];
41+
final optionBuildMap = (builders?['flutter_gen_runner'] ??
42+
builders?['flutter_gen'])?['options'];
43+
if (optionBuildMap is YamlMap) {
4444
final buildMap = {'flutter_gen': optionBuildMap};
4545
mergedMap = mergeMap([mergedMap, buildMap]);
4646
final buildLocaleHint = normalize(

packages/core/test/assets_gen_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,18 @@ void main() {
225225
await expectedAssetsGen(pubspec, generated, fact, build: build);
226226
},
227227
);
228+
229+
test(
230+
'Assets on pubspec_assets.yaml and override with build_runner_assets.yaml ',
231+
() async {
232+
const pubspec = 'test_resources/pubspec_assets.yaml';
233+
const build = 'test_resources/build_runnfer_assets.yaml';
234+
const fact = 'test_resources/actual_data/build_assets.gen.dart';
235+
const generated = 'test_resources/lib/build_gen/assets.gen.dart';
236+
237+
await expectedAssetsGen(pubspec, generated, fact, build: build);
238+
},
239+
);
228240
});
229241

230242
group('Test generatePackageNameForConfig', () {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: test
2+
3+
targets:
4+
$default:
5+
builders:
6+
flutter_gen_runner:
7+
options:
8+
output: lib/build_gen/
9+
line_length: 120

0 commit comments

Comments
 (0)