How To Create Crop Image Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

image_cropper packages in flutter. Image picker package is used to pick image from Gallery or Camera of the phone. Image croppper can be used to crop an image. image_cropper package uses platform channels to communicate with native libraries uCrop in Android and TOCropViewController in iOS. The package can be used for basic photo editing like crop and rotate images.

How To Create Crop Image Using Flutter Android App

Crop Image
Complete Code For Crop Image In Flutter
main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>{
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
        centerTitle: true,
        title: Text('Crop Image'),
      ),
      body: Center(
        child: AspectRatio(
          aspectRatio: 387 / 430,
          child: Container(
              decoration: BoxDecoration(
                image: DecorationImage(
                  fit: BoxFit.fitWidth,
                  alignment: FractionalOffset.topCenter,
                  image: ExactAssetImage('assets/images/image2.jpg'),
                ),
              )),
        ),
      ),
    );
  }
}

Related Post