scanbot_image_picker 1.0.0-beta2 scanbot_image_picker: ^1.0.0-beta2 copied to clipboard
Simple Image Picker with single and multiple selection capability.
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: () {
pickImageFromPhotoGallery();
},
)),
),
);
}
/// picks multiple images from photo gallery and prints the output of selected image uris.
Future pickImagesFromPhotoGallery() async {
var uris = await ScanbotImagePickerFlutter.pickImagesAsync();
for (var uri in uris) {
print(uri.path);
}
}
/// picks single image from photo gallery and prints the output of selected image uris.
Future pickImageFromPhotoGallery() async {
var uri = await ScanbotImagePickerFlutter.pickImageAsync();
print(uri.path);
}
}