Flutter Package to Pick Image From Gallery or Camera

Overview

image_picker_gallery_camera

Flutter Package to Pick Image From Gallery or Camera

Getting Started

A Flutter plugin for iOS and Android for picking images from the image library, and taking new pictures with the camera. You can use both Camera and Gallery Option.

Installation

First, add image_picker_gallery_camera as a dependency in your pubspec.yaml file.

iOS

Add the following keys to your Info.plist file, located in /ios/Runner/Info.plist:

NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
NSMicrophoneUsageDescription - describe why your app needs access to the microphone, if you intend to record videos. This is called Privacy - Microphone Usage Description in the visual editor.

Android

No configuration required - the plugin should work out of the box.

Final Output

Example

[ Container( width: 300, child: ElevatedButton( onPressed: () => getImage(ImgSource.Gallery), style: ElevatedButton.styleFrom( primary: Colors.blue, ), child: Text( "From Gallery".toUpperCase(), style: TextStyle(color: Colors.white), ), ), ), Container( width: 300, child: ElevatedButton( onPressed: () => getImage(ImgSource.Camera), style: ElevatedButton.styleFrom( primary: Colors.deepPurple, ), child: Text( "From Camera".toUpperCase(), style: TextStyle(color: Colors.white), ), ), ), Container( width: 300, child: ElevatedButton( onPressed: () => getImage(ImgSource.Both), style: ElevatedButton.styleFrom( primary: Colors.red, ), child: Text( "Both".toUpperCase(), style: TextStyle(color: Colors.white), ), ), ), _image != null ? Image.file(File(_image.path)) : Container(), ], ), ), ), ); } } ">
import 'dart:io';

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example Image Picker',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Example Image Picker'),
    );
  }
}

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

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State
   
     {
  var _image;

  Future getImage(ImgSource source) async {
    var image = await ImagePickerGC.pickImage(
        enableCloseButton: true,
        closeIcon: Icon(
          Icons.close,
          color: Colors.red,
          size: 12,
        ),
        context: context,
        source: source,
        barrierDismissible: true,
        cameraIcon: Icon(
          Icons.camera_alt,
          color: Colors.red,
        ), //cameraIcon and galleryIcon can change. If no icon provided default icon will be present
        cameraText: Text(
          "From Camera",
          style: TextStyle(color: Colors.red),
        ),
        galleryText: Text(
          "From Gallery",
          style: TextStyle(color: Colors.blue),
        ));
    setState(() {
      _image = image;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: 
    
     [
              Container(
                width: 300,
                child: ElevatedButton(
                  onPressed: () => getImage(ImgSource.Gallery),
                  style: ElevatedButton.styleFrom(
                    primary: Colors.blue,
                  ),
                  child: Text(
                    "From Gallery".toUpperCase(),
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
              Container(
                width: 300,
                child: ElevatedButton(
                  onPressed: () => getImage(ImgSource.Camera),
                  style: ElevatedButton.styleFrom(
                    primary: Colors.deepPurple,
                  ),
                  child: Text(
                    "From Camera".toUpperCase(),
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
              Container(
                width: 300,
                child: ElevatedButton(
                  onPressed: () => getImage(ImgSource.Both),
                  style: ElevatedButton.styleFrom(
                    primary: Colors.red,
                  ),
                  child: Text(
                    "Both".toUpperCase(),
                    style: TextStyle(color: Colors.white),
                  ),
                ),
              ),
              _image != null ? Image.file(File(_image.path)) : Container(),
            ],
          ),
        ),
      ),
    );
  }
}


    
   
You might also like...

Flutter package for image editing

Flutter package for image editing

You can edit image using this package and also you can create flex preview image by setting foreground to null. For now, you can use only asset files.

Nov 21, 2022

A Flutter widget that paints an image and moves it at a slower speed than the main scrolling content.

A Flutter widget that paints an image and moves it at a slower speed than the main scrolling content.

A Flutter widget that paints an image and moves it at a slower speed than the main scrolling content. Installation Add dependency to your pubspec.yaml

Dec 23, 2022

📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

Flutter Photo View A simple zoomable image/content widget for Flutter. PhotoView enables images to become able to zoom and pan with user gestures such

Jan 3, 2023

Flutter plugin that allows you to display multi image picker on iOS and Android. 👌🔝🎉

Flutter plugin that allows you to display multi image picker on iOS and Android. 👌🔝🎉

IMPORTANT: This repository has been archived and no longer mantained. As I don't have time anymore to work on the package it became very outdated. For

Apr 29, 2021

Image caching system for flutter

image_cacheing image_cacheing is an image caching package. It is currently tested for Android applications. ImageCacheing widget takes url as a param.

May 31, 2021

A simple and easy flutter demo to crop image

flutter_image_crop A simple demo to crop image on flutter easily. A Chinese version of this document can be found here Flutter_image_crop Plugin will

Jul 8, 2021

A flutter tool to generate beautiful code snippets in the form of an image.

A flutter tool to generate beautiful code snippets in the form of an image.

A flutter tool to generate beautiful code snippets in the form of an image.

Jan 18, 2022

Simple and effective cross platform image saver for flutter, supported web and desktop

Simple and effective cross platform image saver for flutter, supported web and desktop

Oct 5, 2022

flutter image demo 主要展示图片与动画处理的案例。比如:网络图片加载、图片预览、图片缩放、json动画处理等等。

flutter image demo 主要展示图片与动画处理的案例。比如:网络图片加载、图片预览、图片缩放、json动画处理等等。

flutter_image_demo flutter image demo 主要展示图片与动画处理的案例。 比如:网络图片加载、图片预览、图片缩放、json动画处理等等。 本项目使用到以下插件: cached_network_image、 photo_view 、 lottie 、 flutter_

Feb 27, 2022
Comments
  • iOS 14 Crash and Feature Request

    iOS 14 Crash and Feature Request

    When selecting From Gallery on iOS 14. Sometimes it works, however most of the time it crashes. We have set all of the necessary permissions so we know that's not an issue

    Also, is there a way to add a cancel button or some way of getting out of the pickImage popup to choose Camera or Gallery? Because at the moment, we are finding it very hard to get out of the screen once we've tapped into it, which will then lead us to a crash

    opened by mogsten 2
  • Make labels customizable

    Make labels customizable

    Hello! Great plugin. Just a small nitpick, you should make the labels "Camera" and "Gallery" customizable, just like you're doing for the icons.

    opened by regisbamba 1
  • Android release error

    Android release error

    Hi, I receive this error when build the app in release mode:

    E/AndroidRuntime(32521): java.lang.IllegalAccessError: Interface androidx.lifecycle.c implemented by class io.flutter.plugins.imagepicker.ImagePickerPlugin$LifeCycleObserver is inaccessible (declaration of 'io.flutter.plugins.imagepicker.ImagePickerPlugin$LifeCycleObserver' appears in /data/app/com.xx.xx-oqT1Drg-_Wryf5a4ZCb2Yw==/base.apk!classes2.dex)

    opened by stoppiNeobiz 0
  • Black image is getting produced as the PDF

    Black image is getting produced as the PDF

    I was trying out the app. In general, it seems to work fine, but sometimes it gives a black image is getting produced as pdf. I have no idea why is this happening. Can you help me on this?

    opened by 0Vipin0 1
Owner
Sayandh KP
Sayandh KP
Flutter gallery - Image, Audio, Video & File.

Flutter Gallery Getting Started For help getting started with Flutter, view our online documentation.

Vivek Sharma 55 Sep 26, 2022
A scrollable, dismissable by swiping, zoomable, rotatable image gallery on which you can add a dynamic overlay.

Swipe Image Gallery A scrollable, dismissable by swiping, zoomable, rotatable image gallery on which you can add a dynamic overlay. While it is intend

null 20 Dec 7, 2022
Loading indicator GIFs. Material and Cupertino (Android and iOS) loading indicators in assorted sizes. Use as placeholders for loading remote image assets. Demo: https://gallery.codelessly.com/flutterwebsites/loadinggifs/

Loading GIFs High quality Android and iOS loading spinners. View Demo Loading GIFs is a collection of high fidelity loading animations in GIF format.

Codelessly 31 Dec 23, 2022
Flutter package for Image Carousel It is an image carousel widget.

Snapshot Carousel Flutter package for Image Carousel It is an image carousel widget. Supported platforms Flutter Android Flutter iOS Flutter web Flutt

Mrigank Anand 12 Jun 3, 2021
A powerful official extension library of image, which support placeholder(loading)/ failed state, cache network, zoom pan image, photo view, slide out page, editor(crop,rotate,flip), paint custom etc.

extended_image Language: English| 中文简体 A powerful official extension library of image, which support placeholder(loading)/ failed state, cache network

FlutterCandies 1.6k Dec 31, 2022
Basic flutter art gallery app

artes_nft A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

null 0 Nov 25, 2021
A simple Flutter Package to Mimic iMessage Image Picker for Flutter

A simple Flutter Package to Mimic iMessage Image Picker for Flutter

Paras Jain 64 Dec 26, 2022
A flutter package to convert any widget to an Image.

Davinci A package to convert any widget to an image which can be saved locally or can be shared to other apps and chats. ?? Preview ℹ️ Usage Prerequis

Sai Gokula Krishnan 37 Dec 20, 2022
Multi image pixker using the image_picker package in flutter

multi_image_selection A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Ambaliya Avnit Karshanbhai 1 Oct 13, 2021
A flutter package for image carousels.

flutter_image_carousel A flutter package for image carousels. Supports both Asset and Network images. Example new ImageCarousel( <ImageProvider>[

Theo Bouwman 53 Aug 9, 2021