'Getting this error on tap function to see an image in a dialog box

onTap: () { showDialog( context: context, builder: (BuildContext context) { return ImageNetwork( image: data['image'].toString(), height: 400, width: 400, duration: 1000, curve: Curves.easeIn, onPointer: true, fitAndroidIos: BoxFit.cover, fitWeb: BoxFitWeb.cover, borderRadius: BorderRadius.circular(50), onLoading: const CircularProgressIndicator( color: Colors.amber, ), ); });

GET THIS ERROR: enter image description here



Solution 1:[1]

Use Dialog widget over your ImageNetwork widget. This will resolve your issue.


onTap:() {
        showDialog(context: context, builder: (BuildContext context) {
          return Dialog(
           child: ImageNetwork(image: data['image'].toString(),
            height: 400,
            width: 400,
            duration: 1000,
            curve: Curves.easeIn,
            onPointer: true,
            fitAndroidIos: BoxFit.cover,
            fitWeb: BoxFitWeb.cover,
            borderRadius: BorderRadius.circular(50),
            onLoading: const CircularProgressIndicator(color: Colors.amber,),),`enter code here`);
        });
      }

Solution 2:[2]

Wrap your ImageNetwork() widget inside Material Widget

And set type to MaterialType.transparency

showDialog(
  context: context,
  builder: (context) => Material(
  type: MaterialType.transparency,
  child: YourWidget(...)
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kashif Niaz
Solution 2 Aditya