scanbot_image_picker 1.0.0-beta3 copy "scanbot_image_picker: ^1.0.0-beta3" to clipboard
scanbot_image_picker: ^1.0.0-beta3 copied to clipboard

Simple Image Picker with single and multiple selection capability.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:scanbot_image_picker/scanbot_image_picker_flutter.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion = await ScanbotImagePickerFlutter.platformVersion ??
          'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Image Picker'),
        ),
        body: Center(
            child: TextButton(
          child: const Text("Pick Images"),
          style: ButtonStyle(
            foregroundColor: MaterialStateProperty.all<Color>(Colors.blue),
          ),
          onPressed: () {
            pickImagesFromPhotoGallery();
          },
        )),
      ),
    );
  }

  /// picks multiple images from photo gallery and prints the output of selected image uris.
  Future pickImagesFromPhotoGallery() async {
    var response = await ScanbotImagePickerFlutter.pickImagesAsync();
    print(response.uris);
    if (response.message?.isNotEmpty == true) {
      print(response.message);
    }
  }

  /// picks single image from photo gallery and prints the output of selected image uris.
  Future pickImageFromPhotoGallery() async {
    var response = await ScanbotImagePickerFlutter.pickImageAsync();
    print(response.uri ?? "");
    if (response.message?.isNotEmpty == true) {
      print(response.message ?? "");
    }
  }

  /// show alert message
  showDialouge(String? message) {
    AlertDialog alert = AlertDialog(
      title: const Text('Alert'),
      content: Text(message ?? ""),
      actions: [
        TextButton(
            onPressed: () {},
            // function used to perform after pressing the button
            child: const Text('Cancel')),
        TextButton(onPressed: () {}, child: const Text('Ok')),
      ],
    );
    showDialog(
        context: this.context,
        builder: (BuildContext context) {
          return alert;
        });
  }
}
3
likes
0
pub points
78%
popularity

Publisher

verified publisherscanbot.io

Simple Image Picker with single and multiple selection capability.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, image_picker

More

Packages that depend on scanbot_image_picker