Skip to content

Commit 9e4f630

Browse files
authored
fix: #323 TypeError when list json with lottie (#324)
1 parent c43af97 commit 9e4f630

19 files changed

+61
-28
lines changed

example/assets/json/list.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
{
3+
"id": "ABC42"
4+
}
5+
]
File renamed without changes.

example/lib/gen/assets.gen.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ class $AssetsImagesGen {
5656
class $AssetsJsonGen {
5757
const $AssetsJsonGen();
5858

59-
/// File path: assets/json/fruits.json
60-
String get fruits => 'assets/json/fruits.json';
59+
/// File path: assets/json/list.json
60+
String get list => 'assets/json/list.json';
61+
62+
/// File path: assets/json/map.json
63+
String get map => 'assets/json/map.json';
6164

6265
/// List of all assets
63-
List<String> get values => [fruits];
66+
List<String> get values => [list, map];
6467
}
6568

6669
class $AssetsLottieGen {

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ flutter:
166166
- assets/images/icons/kmm.svg
167167
- assets/images/icons/paint.svg
168168
- assets/images/icons/[email protected]
169-
- assets/json/fruits.json
169+
- assets/json/
170170
- pictures/chip5.jpg
171171
- assets/flare/
172172
- assets/rive/

packages/core/lib/generators/integrations/lottie_integration.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ class LottieIntegration extends Integration {
120120
} on FormatException catch (e) {
121121
// Catches bad/corrupted json and reports it to user.
122122
stderr.writeln(e.message);
123+
} on TypeError catch(e) {
124+
// Catches bad/corrupted json and reports it to user.
125+
stderr.writeln(e);
123126
}
124127
return false;
125128
}

packages/core/test/colors_gen_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void main() {
5050
expect(colorPath.isXml, isTrue);
5151

5252
const wrongColorPath =
53-
ColorPath('test_resources/assets/json/fruits.json');
53+
ColorPath('test_resources/assets/json/map.json');
5454
expect(wrongColorPath.isXml, isFalse);
5555
});
5656

packages/core/test_resources/actual_data/assets.gen.dart

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/test_resources/actual_data/assets_camel_case.gen.dart

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/test_resources/actual_data/assets_no_integrations.gen.dart

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/test_resources/actual_data/assets_package_exclude_files.gen.dart

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)