Skip to content

Commit 0452cb3

Browse files
committed
update document
1 parent 4c279dd commit 0452cb3

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

README.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fluttergen -c example/pubspec.yaml
135135
## Configuration file
136136

137137
[FlutterGen] generates dart files based on the key **`flutter`** and **`flutter_gen`** of [`pubspec.yaml`](https://dart.dev/tools/pub/pubspec).
138-
Default configuration can be found [here](https://github.com/FlutterGen/flutter_gen/tree/main/packages/core/lib/settings/config_default.dart).
138+
Default configuration can be found [here](https://github.com/FlutterGen/flutter_gen/tree/main/packages/core/lib/settings/config_default.dart).
139139

140140
```yaml
141141
# pubspec.yaml
@@ -173,7 +173,6 @@ flutter:
173173

174174
You can also configure generate options in the `build.yaml`, it will be read before the `pubspec.yaml` if it exists.
175175

176-
177176
```yaml
178177
# build.yaml
179178
# ...
@@ -276,7 +275,9 @@ Widget build(BuildContext context) {
276275
);
277276
}
278277
```
278+
279279
or
280+
280281
```dart
281282
// Explicit usage for `Image`/`SvgPicture`/`Lottie`.
282283
Widget build(BuildContext context) {
@@ -340,6 +341,28 @@ Widget build(BuildContext context) {
340341
}
341342
```
342343

344+
When we need to obtain more animation details, we can use the `parse_animation` option. This will automatically parse all animation information for GIFs and WebP files, including frames, duration, etc. As this option significantly increases generation time, it's disabled by default and needs to be manually enabled.
345+
346+
```yaml
347+
flutter_gen:
348+
parse_animation: true # <- Add this line (default: false)
349+
# This option implies parse_metadata: true
350+
```
351+
352+
For GIF and WebP animation, several new nullable field is added to the
353+
generated class. For example:
354+
355+
```dart
356+
AssetGenImage get animated =>
357+
const AssetGenImage(
358+
'assets/images/animated.webp',
359+
size: Size(209.0, 49.0),
360+
isAnimation: true,
361+
duration: Duration(milliseconds: 1000),
362+
frames: 15,
363+
);
364+
```
365+
343366
#### Usage Example
344367

345368
[FlutterGen] generates [Image](https://api.flutter.dev/flutter/widgets/Image-class.html) class if the asset is Flutter supported image format.
@@ -575,7 +598,9 @@ Plugin issues that are not specific to [FlutterGen] can be filed in the [Flutter
575598
### Known Issues
576599

577600
#### Bad State: No Element when using build_runner
601+
578602
If you get an error message like this:
603+
579604
```
580605
[SEVERE] flutter_gen_runner:flutter_gen_runner on $package$:
581606
@@ -614,7 +639,7 @@ output-localization-file: app_localizations.dart
614639
synthetic-package: false <--- ⚠️Add this line⚠️
615640
```
616641

617-
If you get
642+
If you get
618643

619644
## Contributing
620645

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''}
136136
if (info.animation case final animation?) {
137137
buffer.write(', isAnimation: ${animation.frames > 1}');
138138
buffer.write(
139-
', duration: const Duration(milliseconds: ${animation.duration.inMilliseconds})',
139+
', duration: Duration(milliseconds: ${animation.duration.inMilliseconds})',
140140
);
141141
buffer.write(', frames: ${animation.frames}');
142142
}

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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)