File tree Expand file tree Collapse file tree 5 files changed +17
-13
lines changed
pkgs/hooks_runner/test_data Expand file tree Collapse file tree 5 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,6 @@ import 'package:hooks/hooks.dart';
9
9
// it lands on stable https://github.com/dart-lang/sdk/issues/61166.
10
10
void main (List <String > args) async {
11
11
await link (args, (input, output) async {
12
- output.registerFlagUse (input.packageName, ['de' ]);
12
+ output.registerCountryUse (input.packageName, ['de' ]);
13
13
});
14
14
}
Original file line number Diff line number Diff line change @@ -9,6 +9,6 @@ import 'package:hooks/hooks.dart';
9
9
// it lands on stable https://github.com/dart-lang/sdk/issues/61166.
10
10
void main (List <String > args) async {
11
11
await link (args, (input, output) async {
12
- output.registerFlagUse (input.packageName, ['fr' ]);
12
+ output.registerCountryUse (input.packageName, ['fr' ]);
13
13
});
14
14
}
Original file line number Diff line number Diff line change @@ -9,10 +9,7 @@ import 'package:hooks/hooks.dart';
9
9
void main (List <String > args) {
10
10
link (args, (input, output) async {
11
11
print ('Metadata: ${input .metadata }' );
12
- final usedFlags = input.metadata.entries
13
- .where ((entry) => entry.key.startsWith (prefix))
14
- .expand ((e) => e.value as List )
15
- .map ((e) => e as String )
12
+ final usedFlags = input.fetchUsedCountries
16
13
.map ((country) => 'package:fun_with_flags/assets/$country .txt' )
17
14
.toSet ();
18
15
Original file line number Diff line number Diff line change 2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- export 'src/hook.dart' show FlagsUsed ;
5
+ export 'src/hook.dart' show FlagsUsedWrite ;
Original file line number Diff line number Diff line change 2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- import 'package:hooks/hooks.dart' show LinkOutputBuilder;
5
+ import 'package:hooks/hooks.dart' show LinkInput, LinkOutputBuilder;
6
6
7
- const prefix = 'used_flags_' ;
7
+ const _prefix = 'used_flags_' ;
8
8
9
- extension FlagsUsed on LinkOutputBuilder {
9
+ extension FlagsUsedWrite on LinkOutputBuilder {
10
10
/// Register a list of flags to be kept from treeshaking.
11
11
///
12
- /// This uses the [callerPackageName] with the [prefix ] to make a unique
12
+ /// This uses the [callerPackageName] with the [_prefix ] to make a unique
13
13
/// identifier for this list - that's how we avoid overwriting other
14
14
/// packages flags.
15
- void registerFlagUse (String callerPackageName, List <String > countries) =>
16
- metadata.add ('fun_with_flags' , '$prefix $callerPackageName ' , countries);
15
+ void registerCountryUse (String callerPackageName, List <String > countries) =>
16
+ metadata.add ('fun_with_flags' , '$_prefix $callerPackageName ' , countries);
17
+ }
18
+
19
+ extension FlagsUsedRead on LinkInput {
20
+ Iterable <String > get fetchUsedCountries => metadata.entries
21
+ .where ((entry) => entry.key.startsWith (_prefix))
22
+ .expand ((e) => e.value as List )
23
+ .map ((e) => e as String );
17
24
}
You can’t perform that action at this time.
0 commit comments