camera_gallery_photopicker 0.0.6 copy "camera_gallery_photopicker: ^0.0.6" to clipboard
camera_gallery_photopicker: ^0.0.6 copied to clipboard

A simple Flutter package that allows easy image picking from the gallery or camera. It presents a bottom sheet UI for selecting the image source and returns the selected image to your app via a callba [...]

camera_gallery_photopicker #

A modern Flutter package to pick images easily from the device gallery or camera. It presents a Material 3 bottom sheet UI with customizable options, theme awareness, and supports Dart 3 async safety.

Pub Version License: MIT Buy Me a Coffee


Features #

  • 📸 Gallery & Camera Pickers: Pick images seamlessly from the photo gallery or camera.
  • 🎨 Material 3 UI: Beautiful, rounded bottom sheet design with drag handle bar and ripple effects.
  • 🌓 Theme Aware: Automatically matches your application's light and dark themes.
  • ⚙️ Fully Customizable: Customize titles, icons, background colors, shapes, text styles, and compression quality.
  • Cross-Platform Friendly: Provides callbacks for both File and XFile.
  • 🔒 Dart 3 Safe: Includes built-in mounted checks across async gaps.

Installation #

Add camera_gallery_photopicker to your pubspec.yaml:

dependencies:
  camera_gallery_photopicker: ^0.0.6

Then run:

flutter pub get

Usage #

1. Simple Usage #

Import the package and call ImagePickerHelper.showImagePickerOption:

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:camera_gallery_photopicker/camera_gallery_photopicker.dart';

void pickImage(BuildContext context) {
  ImagePickerHelper.showImagePickerOption(
    context,
    (File imageFile) {
      print('Selected image path: ${imageFile.path}');
    },
  );
}

2. Custom Usage #

You can customize titles, icons, bottom sheet styles, and image compression parameters:

ImagePickerHelper.showImagePickerOption(
  context,
  (File imageFile) {
    // Handle picked File
  },
  onXFilePicked: (XFile xFile) {
    // Handle picked XFile (useful for Web)
  },
  sheetTitle: 'Select Profile Picture',
  galleryTitle: 'Choose from Gallery',
  cameraTitle: 'Take a Photo',
  galleryIcon: const Icon(Icons.photo_library, color: Colors.blue, size: 40),
  cameraIcon: const Icon(Icons.camera_alt, color: Colors.green, size: 40),
  imageQuality: 85,
  maxWidth: 1080,
  maxHeight: 1080,
);

Complete Example #

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:camera_gallery_photopicker/camera_gallery_photopicker.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.light(useMaterial3: true),
      darkTheme: ThemeData.dark(useMaterial3: true),
      home: const ImagePickerScreen(),
    );
  }
}

class ImagePickerScreen extends StatefulWidget {
  const ImagePickerScreen({super.key});

  @override
  State<ImagePickerScreen> createState() => _ImagePickerScreenState();
}

class _ImagePickerScreenState extends State<ImagePickerScreen> {
  File? _selectedImage;

  void _openImagePicker() {
    ImagePickerHelper.showImagePickerOption(
      context,
      (File image) {
        setState(() {
          _selectedImage = image;
        });
      },
      sheetTitle: 'Pick an Image',
      imageQuality: 80,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Image Picker Demo')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            _selectedImage != null
                ? Image.file(_selectedImage!, height: 200, fit: BoxFit.cover)
                : const Text('No image selected.'),
            const SizedBox(height: 20),
            ElevatedButton.icon(
              onPressed: _openImagePicker,
              icon: const Icon(Icons.add_a_photo),
              label: const Text('Pick Image'),
            ),
          ],
        ),
      ),
    );
  }
}

License #

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

2
likes
140
points
115
downloads

Documentation

API reference

Publisher

verified publishermahafujerrahman.xyz

Weekly Downloads

A simple Flutter package that allows easy image picking from the gallery or camera. It presents a bottom sheet UI for selecting the image source and returns the selected image to your app via a callback function. Compatible with Flutter 2.0+ and supports null safety.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, image_picker

More

Packages that depend on camera_gallery_photopicker