Skip to content

[BUG]: Import conflict: Image class defined in flutter and rive #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
codeOfJannik opened this issue Jul 26, 2024 · 15 comments · Fixed by #548
Closed
2 tasks done

[BUG]: Import conflict: Image class defined in flutter and rive #545

codeOfJannik opened this issue Jul 26, 2024 · 15 comments · Fixed by #548
Labels
bug Something isn't working
Milestone

Comments

@codeOfJannik
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Version

5.6.0

Command type

build_runner (Default)

What happened?

Out of nowhere we started to get an error in the generated file that a image class is found both in package/flutter/...widgets.dart and package/rive:
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)'.

Anyone else already faced that issue? Has anything changed in the package?
Or did something change in rive, e.g. they started to export the image class so it's visible?

A workaround for now is to add a hide Image to the rive import manually after the assets.gen.dart file has been generated.

Our assets folder contains png, jpg, svg and riv files.

Relevant a pubspec.yaml.

dependencies:
  flutter:
    sdk: flutter
  flutter_svg: ^2.0.10+1
  rive: ^0.13.12

dev_dependencies:
  build_runner: ^2.4.11
  flutter_gen_runner: ^5.6.0
  flutter_test:
    sdk: flutter

flutter:
  assets:
    - assets/
    - assets/animations/
    - assets/images/
    - assets/images/first_time_ux/
    - assets/images/first_time_ux/alerting/de/
    - assets/images/first_time_ux/alerting/en/
    - assets/images/group/
    - assets/images/menu_icons/


flutter_gen:
  output: lib/src/generated/
  line_length: 180
  assets:
    outputs:
      package_parameter_enabled: true

  integrations:
    flutter_svg: true
    rive: true

Relevant log output

FlutterGen v5.6.0 Loading ... pubspec.yaml
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 903ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Deleting 1 declared outputs which already existed on disk.
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms

[INFO] Running build...
Generated: lib/src/generated/assets.gen.dart
FlutterGen finished.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@codeOfJannik codeOfJannik added the bug Something isn't working label Jul 26, 2024
@mhammerc
Copy link

mhammerc commented Jul 26, 2024

Hello,

The error appears starting with rive version 0.13.10.

Version 0.13.9 doesn't export Image. For now, we will stay on rive 0.13.9 so we "avoid" this error.

@AlexV525
Copy link
Member

Sounds like a rive issue which means the issue should be reported to the rive package?

@codeOfJannik
Copy link
Author

Why? If the rive package needs to export the image class they can do that. The flutter_gen rive import statement should be adjusted to hide Image from rive

@Sevastyan
Copy link

Not hide, but flutter_gen must have been using aliases for imports in the first place. Otherwise, the issue might return.

@AlexV525
Copy link
Member

AlexV525 commented Aug 6, 2024

We have a relatively long releasing procedure. If you're encountering the issue you can use the fix in the PR #548 by overriding dependencies.

@mhammerc
Copy link

mhammerc commented Aug 6, 2024

We have a relatively long releasing procedure. If you're encountering the issue you can use the fix in the PR #548 by overriding dependencies.

Hello,

Just wanted to say thank you for the upcoming fix and the ongoing support of flutter_gen. This is what makes the Flutter community thrive, and it helps many.

@msxenon
Copy link

msxenon commented Aug 8, 2024

its better to use import alias just like mockito generator)

@usmanovrustam
Copy link

usmanovrustam commented Sep 3, 2024

The Issue is closed, anyway I fixed problem by using older version of rive(0.13.5). Idk why contributors of rive added Image class in the new version!

@AlexV525
Copy link
Member

AlexV525 commented Sep 3, 2024

The issue is closed because the fix has been shipped through the v5.7.0 version.

@usmanovrustam

This comment was marked as off-topic.

@AlexV525

This comment was marked as off-topic.

@usmanovrustam

This comment was marked as off-topic.

@AlexV525

This comment was marked as off-topic.

@usmanovrustam

This comment was marked as off-topic.

@AlexV525

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants