MO-Fuel-Tax-Back/lib/widgets/image_source_sheet.dart

28 lines
1,006 B
Dart

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
/// Bottom sheet letting the user pick a photo from the camera or their
/// existing library. Shared by any screen that needs to snap or choose a
/// photo (receipt capture, VIN scanning) so the choice looks and behaves
/// the same everywhere.
Future<ImageSource?> chooseImageSource(BuildContext context) {
return showModalBottomSheet<ImageSource>(
context: context,
builder: (context) => SafeArea(
child: Wrap(
children: [
ListTile(
leading: const Icon(Icons.camera_alt_outlined),
title: const Text('Take Photo'),
onTap: () => Navigator.of(context).pop(ImageSource.camera),
),
ListTile(
leading: const Icon(Icons.photo_library_outlined),
title: const Text('Choose from Gallery'),
onTap: () => Navigator.of(context).pop(ImageSource.gallery),
),
],
),
),
);
}