Issue in interactive viewer zooming,when Interactive viewer is a child of Container

Issue

I am zoom a image inside interactive viewer , interactive viewer is a child of container ,set some height to container,after zoom a image, particular position in viewport ,i cant scroll and zoom a image


 class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: Zoom(),
      ),
    );
  }
}
class Zoom extends StatefulWidget
{
  @override
  MyStatelessWidget createState()=> MyStatelessWidget();
}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends State<Zoom> {


  @override
  Widget build(BuildContext context) {
    return Center(
child:Container(height: 300,
      child: InteractiveViewer(

       scaleEnabled: true,maxScale: 4.0,
        child: Center(
         child:Container( child:Image.asset('Assets/Java-001.jpg',fit: BoxFit.cover,alignment: Alignment.center,)),
      ),
    )));
  }
}


How can i resolve this problem?

Solution

Try adding these arguments to the InteractiveViewer widget:

minScale: 0.1,
maxScale: 4.0,
boundaryMargin: const EdgeInsets.all(double.infinity),
constrained: false,

Answered By – Roslan Amir

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.