There is a conflict when using the flutter_gen package with the rive dependency versions. The generated file has an ambiguous import error with the Image class from Flutter and Rive. This issue is caused by the overlapping Image class names in Flutter and Rive packages. A potential solution could be to use aliases or hide directives in the generated file.
Steps to Reproduce
Use pubspec.yaml configuration.
Add a sample Rive file (download from Rive Community) to the assets/rive/ folder.
Add a sample image file to the assets/images/ folder.
Run the command fluttergen to generate the required files.
Expected Behavior
The usage should be without any errors, and the generated file should properly integrate Rive and image assets.
Actual Behavior
The usage of image throws an error due to an ambiguous import of the Image class from both package:flutter/src/widgets/image.dart and package:rive/src/rive_core/shapes/image.dart.
For example, when using Assets.images.appIcon.image()
The argument type 'dynamic' can't be assigned to the parameter type 'Widget?'. dartargument_type_not_assignable
In the generated file
The name 'Image' is defined in the libraries 'package:flutter/src/widgets/image.dart (via package:flutter/widgets.dart)' and 'package:rive/src/rive_core/shapes/image.dart (via package:rive/rive.dart)'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.dartambiguous_import
Workaround
Downgrading rive to version 0.13.9 resolves the issue, but any version above causes the conflict.
Is there an existing issue for this?
Version
5.6.0
Command type
Dart command
What happened?
There is a conflict when using the
flutter_gen
package with therive
dependency versions. The generated file has an ambiguous import error with theImage
class fromFlutter
andRive
. This issue is caused by the overlapping Image class names in Flutter and Rive packages. A potential solution could be to use aliases or hide directives in the generated file.Steps to Reproduce
pubspec.yaml
configuration.assets/rive/
folder.assets/images/
folder.fluttergen
to generate the required files.Expected Behavior
The usage should be without any errors, and the generated file should properly integrate Rive and image assets.
Actual Behavior
The usage of
image
throws an error due to an ambiguous import of the Image class from bothpackage:flutter/src/widgets/image.dart
andpackage:rive/src/rive_core/shapes/image.dart
.For example, when using
Assets.images.appIcon.image()
In the generated file
Workaround
Downgrading
rive
toversion 0.13.9
resolves the issue, but any version above causes the conflict.Environment
Relevant a pubspec.yaml.
Relevant log output
No response
Code of Conduct