Skip to main content

mosaic_image_picker 0.1.1 copy "mosaic_image_picker: ^0.1.1" to clipboard
mosaic_image_picker: ^0.1.1 copied to clipboard

A Flutter package for creating image mosaics with drag, pinch-to-zoom, and automatic image optimization. Perfect for creating collages and photo grids.

Mosaic Image Picker #

A Flutter package for creating beautiful image mosaics with drag, pinch-to-zoom, and automatic image optimization. Perfect for creating photo collages and grids in your Flutter apps.

pub package License: MIT

Features #

✨ Easy to Use - Simple API with just one method call
📱 Mobile First - Optimized for iOS and Android
🎨 Flexible Layouts - Support for 1, 2, 3, or 4 image grids
👆 Intuitive Gestures - Drag with 2 fingers, pinch to zoom
🖼️ Auto Optimization - Automatic EXIF rotation fix and image compression
⚡ Performance - Optimized image handling for smooth user experience
🎯 Final Output - Generates a single composed image ready to save

Demo #

2 Horizontal Layout 2 Vertical Layout 3 Vertical Layout 2x2 Grid Layout
2 Horizontal 2 Vertical 3 Vertical 2x2 Grid

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  mosaic_image_picker: ^0.0.1

Then run:

flutter pub get

Usage #

Basic Example #

import 'package:flutter/material.dart';
import 'package:mosaic_image_picker/mosaic_image_picker.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Image Mosaic Creator')),
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              // Show the mosaic creator
              final result = await ImageMosaicCreator.show(context);
              
              if (result != null && result.images.isNotEmpty) {
                // result.images[0] is the final optimized composed mosaic
                final composedImage = result.images[0];
                
                // Use the image as needed
                print('Mosaic created: ${composedImage.path}');
              }
            },
            child: Text('Create Mosaic'),
          ),
        ),
      ),
    );
  }
}

Dark Mode Example #

final result = await ImageMosaicCreator.show(
  context,
  backgroundColor: Colors.black,
  secondaryColor: Colors.white,
);

Custom Confirm Button #

final result = await ImageMosaicCreator.show(
  context,
  confirmButton: FloatingActionButton(
    onPressed: () {}, // Will be replaced with actual confirm action
    backgroundColor: Colors.deepPurple,
    child: const Icon(Icons.check),
  ),
  backgroundColor: Colors.white,
  secondaryColor: Colors.deepPurple,
);

if (result != null && result.images.isNotEmpty) {
  // result.images[0] contains the final composed mosaic
  print('Mosaic created successfully!');
}

Available Layouts #

The package supports 5 different layout types:

Layout Description Slots
MosaicLayout.single Single full image 1
MosaicLayout.twoHorizontal 2 images stacked horizontally 2
MosaicLayout.twoVertical 2 images side by side 2
MosaicLayout.threeVertical 3 images stacked vertically 3
MosaicLayout.fourGrid 2x2 grid of images 4

Gestures #

  • Tap empty slot to pick an image
  • Two-finger drag to reposition image
  • Pinch to zoom in/out (0.1x to 3.0x)
  • Tap X button to remove an image

Image Optimization #

The package automatically:

  • Fixes EXIF rotation issues (images from camera)
  • Resizes images to optimal dimensions (max 2560px)
  • Compresses with high quality (95% JPEG)
  • Reduces file size while maintaining visual quality

Advanced Usage #

Accessing Layout Information #

final result = await ImageMosaicCreator.show(context);

if (result != null) {
  print('Layout used: ${result.layout}');
  print('Number of images: ${result.images.length}');
  print('Positions: ${result.positions}');
  print('Scales: ${result.scales}');
}

Manual Image Optimization #

import 'package:mosaic_image_picker/mosaic_image_picker.dart';

// Optimize a single image
XFile optimizedImage = await MediaOptimizationService.optimizeImage(originalImage);

// Fix EXIF rotation
File fixedImage = await MediaOptimizationService.fixExifRotation(imagePath);

Platform Support #

Platform Supported
Android ✅
iOS ✅
Web ⚠️ Limited (no video support)
Desktop ❌ Not tested

Permissions #

iOS (Info.plist) #

<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photos to create mosaics</string>
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to take photos</string>

Android (AndroidManifest.xml) #

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>

For Android 13+, also add:

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

Dependencies #

This package uses the following dependencies:

  • image_picker - For picking images from gallery/camera
  • image - For image processing and optimization
  • permission_handler - For requesting permissions
  • path_provider - For temporary file storage
  • exif - For reading and fixing EXIF data
  • video_compress, video_player, video_thumbnail - For optional video support
  • device_info_plus - For Android version detection

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Author #

Created with ❤️ for the Flutter community

Changelog #

See CHANGELOG.md for a list of changes.

Issues and Feedback #

Please file issues, bugs, or feature requests in our issue tracker.

Support #

If you find this package useful, please consider:

  • ⭐ Starring the repository
  • 🐛 Filing issues and feature requests
  • 📝 Contributing to the codebase
  • 📣 Sharing with other Flutter developers
0
likes
140
points
18
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package for creating image mosaics with drag, pinch-to-zoom, and automatic image optimization. Perfect for creating collages and photo grids.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

device_info_plus, exif, flutter, image, image_picker, path_provider, permission_handler, video_compress, video_player, video_thumbnail

More

Packages that depend on mosaic_image_picker