multi_image_crop 0.0.3 copy "multi_image_crop: ^0.0.3" to clipboard
multi_image_crop: ^0.0.3 copied to clipboard

A flutter package to crop multiple images at a time on iOS and Android.

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:multi_image_crop/multi_image_crop.dart';
import 'package:image_picker/image_picker.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MultiCrop Image',
      debugShowCheckedModeBanner: false,
      theme:
          ThemeData(primarySwatch: Colors.yellow, primaryColor: Colors.yellow),
      home: const MyHomePage(title: 'Multi Crop Image'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<XFile>? receivedFiles = [];
  List<File> croppedFiles = [];
  final ImagePicker _picker = ImagePicker();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView.builder(
          itemCount: croppedFiles.length,
          itemBuilder: (context, index) {
            return Container(
                height: 250,
                padding: const EdgeInsets.all(10.0),
                child: Image.file(
                  croppedFiles[index],
                  fit: BoxFit.fitWidth,
                ));
          }),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          chooseImage();
        },
        child: const Icon(Icons.add),
      ),
    );
  }

  void chooseImage() async {
    receivedFiles = await _picker.pickMultiImage();
    MultiImageCrop.startCropping(
        context: context,
        aspectRatio: 4 / 3,
        activeColor: Colors.amber,
        pixelRatio: 3,
        files: List.generate(
            receivedFiles!.length, (index) => File(receivedFiles![index].path)),
        callBack: (List<File> images) {
          setState(() {
            croppedFiles = images;
          });
        });
  }
}
29
likes
130
points
62
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter package to crop multiple images at a time on iOS and Android.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, image_crop, preload_page_view, scroll_to_index

More

Packages that depend on multi_image_crop