How To Create Zoom Image In Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 10-09-2020

A simple zoomable image widget for Flutter PhotoView is useful in full screen exibition cases.Resolves a image provider and show the result with useful gestures support, such as pinch to zoom and pan.

How To Create Zoom Image In Flutter Android App

Step 1
We cannot directly remove the time stamp from  Zoom Image  but using the intl.dart package we can easily filter the date stamp from time stamp. So open your flutter project’s pubspec.yaml in code .

dependencies:
  flutter:
    sdk: flutter
  photo_view: ^0.10.2

Step 2
After done saving the pubspec.yaml file, Open your flutter project root folder in Command Prompt or Terminal and execute flutter pub get command. 
flutter pub get


Step 3
 Open your project’s main.dart file and import material.dart and  photo_view: ^0.10.2.dart package.
import 'package:photo_view/photo_view.dart';


Complete Code For Zoom Image In Flutter
main.dart
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';


void main() => runApp(MyApp());

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
        home: Scaffold(
            body: ZoomImage()
        )
    );
  }
}

class ZoomImage extends StatefulWidget {

  ZoomImageState createState() => ZoomImageState();

}

class ZoomImageState extends State<ZoomImage>{

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          centerTitle: true,
            leading: InkWell(
              onTap: () {
//                Navigator.pop(context);
              },
              child: Icon(Icons.close),
            ),
            backgroundColor: Colors.pink,
            title: Text('Zoom Image')),
        body: Container(
            child: PhotoView(
              imageProvider: AssetImage("assets/images/photo.jpg"),
            )
        ),
    );
  }
}

Related Post