Skip to content
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

Error: Cannot invoke a non-'const' #52

Closed
MrErkinjon opened this issue Jan 29, 2024 · 5 comments
Closed

Error: Cannot invoke a non-'const' #52

MrErkinjon opened this issue Jan 29, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@MrErkinjon
Copy link

Describe the Issue

../../../.pub-cache/hosted/pub.dev/easy_image_viewer-1.4.0/lib/src/easy_image_provider.dart:85:14: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
child: Column(
^^^^^^

Todo

InkWell(
onTap: () {
showImageViewer(
context,
(workItem.image != "")
? Image.network(
"${BASE_URL_WORK_IMAGE}${workItem.image}")
.image
: Image.network(
"https://t3.ftcdn.net/jpg/04/34/72/82/360_F_434728286_OWQQvAFoXZLdGHlObozsolNeuSxhpr84.jpg")
.image,
swipeDismissible: true,
doubleTapZoomable: true,
useSafeArea: true,
immersive: false);
},
child:Icon(Icons.add)
);

@MrErkinjon
Copy link
Author

environment:
sdk: '>=2.19.6 <4.0.0'
dependencies:
easy_image_viewer: ^1.2.1

@jfahrenkrug
Copy link
Collaborator

@MrErkinjon Hi, thanks for reporting. I can't repro it. I put your (slightly modified) code into the example app and it worked without problems.
Please provide a sample project and the output of flutter doctor. Thank you.

@DerJojo11
Copy link

Hey guys!

I rushed over the same problem here. I also get the same error. I guess you are using Flutter 3.7.0 or lower.

The Problem here is, that Columns are not const for Flutter 3.7 and lower. I just tried it out with a project where I have the a newer Version (3.13.9). So I just looked up and found that columns are const since 3.10

To solve your problem, downgrade to easy_image_viewer: 1.3.2

@jfahrenkrug
Copy link
Collaborator

@DerJojo11 Another Johannes :) Thanks so much for the feedback, that's very helpful. I'll work on a fix.

@jfahrenkrug jfahrenkrug self-assigned this Feb 7, 2024
@jfahrenkrug jfahrenkrug added the bug Something isn't working label Feb 7, 2024
jfahrenkrug added a commit that referenced this issue Feb 8, 2024
Also fix the const Column issue (GH-52).
Flutter 3.7.0 is over one year old. Supporting even older versions
would be too much effort. One year seems reasonable.
jfahrenkrug added a commit that referenced this issue Feb 8, 2024
* Adjust GitHub Actions to run tests on multiple versions of Flutter

The reason is to be better equipped to catch issues that only happen
on older or newer versions of Flutter.

* Switch to flutter-action@v2

* Downgrade flutter_lints to 2.0.3 to support testing on older Flutter versions

Installing deps was failing for older supported Flutter/Dart versions because
flutter_lints 3 needs at least Dart 3.

* Raise min version to Flutter 3.0 and Dart 2.17

* Downgrade flutter_lints to 2.0.1 to make it compatible with Dart 2.17.0

We are trying to keep it backwards-compatible to Dart 2.17 and Flutter 3.0.0.

* Raise min Flutter to 3.7.0 and Dart to 2.19.0

Also fix the const Column issue (GH-52).
Flutter 3.7.0 is over one year old. Supporting even older versions
would be too much effort. One year seems reasonable.

* Bump version to 1.4.1
@jfahrenkrug
Copy link
Collaborator

Fixed in 1.4.1, closing this ticket.

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

No branches or pull requests

3 participants