flutter_album_picker_camera 0.3.1
flutter_album_picker_camera: ^0.3.1 copied to clipboard
Native iOS album picker and camera for Flutter with thumbnail flight animation and a pluggable upload flow.
import 'package:flutter/material.dart';
import 'package:flutter_album_picker_camera/flutter_album_picker_camera.dart';
void main() => runApp(const PickerExampleApp());
class PickerExampleApp extends StatelessWidget {
const PickerExampleApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.dark(useMaterial3: true),
home: const PickerExampleScreen(),
);
}
class PickerExampleScreen extends StatefulWidget {
const PickerExampleScreen({super.key});
@override
State<PickerExampleScreen> createState() => _PickerExampleScreenState();
}
class _PickerExampleScreenState extends State<PickerExampleScreen> {
List<AlbumPickerAttachment<String>> _attachments = const [];
Future<String> _upload(
AlbumPickerPhoto photo,
AlbumPickerUploadProgress onProgress,
) async {
for (var step = 1; step <= 10; step++) {
await Future<void>.delayed(const Duration(milliseconds: 90));
onProgress(step / 10);
}
return photo.name;
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Album Picker + Camera')),
body: ListView(
padding: const EdgeInsets.all(20),
children: [
Text(
'Tap add, choose or capture photos, then watch each photo fly into '
'its thumbnail and upload.',
style: Theme.of(context).textTheme.bodyLarge,
),
const SizedBox(height: 20),
AlbumPickerAttachmentFlow<String>(
onUpload: _upload,
onChanged: (attachments) {
if (mounted) setState(() => _attachments = attachments);
},
onError: (error, _) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(error.toString())),
);
},
),
const SizedBox(height: 20),
Text(
'${_attachments.where((item) => item.isComplete).length} uploaded',
style: Theme.of(context).textTheme.titleMedium,
),
],
),
);
}