2022-08-31 10:09:36 +02:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
2022-08-31 10:19:57 +02:00
|
|
|
import 'package:flutter_image_picker/src/services/image_picker_service.dart';
|
2022-08-31 10:09:36 +02:00
|
|
|
import 'package:image_picker/image_picker.dart';
|
|
|
|
|
|
|
|
class ImagePickerUI {
|
2022-08-31 10:19:57 +02:00
|
|
|
final ImagePickerService _imagePickerService = ImagePickerService();
|
2022-08-31 11:45:12 +02:00
|
|
|
final double iconSize = 125;
|
2022-08-31 10:09:36 +02:00
|
|
|
|
|
|
|
Future<Uint8List?> pickImageDialog(BuildContext context) async {
|
2022-08-31 11:45:12 +02:00
|
|
|
return await showModalBottomSheet<Uint8List?>(
|
2022-08-31 10:09:36 +02:00
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
2022-08-31 11:45:12 +02:00
|
|
|
return Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
|
|
Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.image),
|
|
|
|
tooltip: 'Choose Image From Gallery',
|
|
|
|
iconSize: iconSize,
|
|
|
|
onPressed: () =>
|
|
|
|
_imagePickerService.pickImage(ImageSource.gallery, context),
|
|
|
|
),
|
|
|
|
const Text("Select file"),
|
|
|
|
],
|
2022-08-31 10:09:36 +02:00
|
|
|
),
|
2022-08-31 11:45:12 +02:00
|
|
|
|
|
|
|
Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.camera_alt_rounded),
|
|
|
|
tooltip: 'Make Image With Camera',
|
|
|
|
iconSize: iconSize,
|
|
|
|
onPressed: () =>
|
|
|
|
_imagePickerService.pickImage(ImageSource.camera, context),
|
|
|
|
),
|
|
|
|
const Text("Take a picture"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
// ElevatedButton(
|
|
|
|
// onPressed: () =>
|
|
|
|
// _imagePickerService.pickImage(ImageSource.gallery, context),
|
|
|
|
// child: const Text('Gallery'),
|
|
|
|
// ),
|
|
|
|
// const SizedBox(width: 10),
|
|
|
|
// ElevatedButton(
|
|
|
|
// onPressed: () =>
|
|
|
|
// _imagePickerService.pickImage(ImageSource.camera, context),
|
|
|
|
// child: const Text('Camera'),
|
|
|
|
// ),
|
|
|
|
]);
|
2022-08-31 10:09:36 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|