thesmythgroup / easy_image_viewer

An easy Flutter image viewer with pinch & zoom support.
MIT License
41 stars 51 forks source link

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

Closed MrErkinjon closed 9 months ago

MrErkinjon commented 9 months ago

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 commented 9 months ago

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

jfahrenkrug commented 9 months ago

@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 commented 9 months ago

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 commented 9 months ago

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

jfahrenkrug commented 9 months ago

Fixed in 1.4.1, closing this ticket.