advanced_media_picker 0.0.5 advanced_media_picker: ^0.0.5 copied to clipboard
This plugin displays a gallery with user's Albums and Photos with ability to take photo and video.
import 'package:advanced_media_picker/advanced_media_picker.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ValueListenableBuilder<List<XFile>>(
valueListenable: selectedFiles,
builder:
(BuildContext context, List<XFile> value, Widget? child) {
return Column(
children: value.map((XFile file) {
return Text(file.path);
}).toList(),
);
},
),
const MyButton(),
],
),
),
);
}
}
final ValueNotifier<List<XFile>> selectedFiles =
ValueNotifier<List<XFile>>(<XFile>[]);
class MyButton extends StatelessWidget {
const MyButton({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: ElevatedButton(
child: const Text('Open Picker'),
onPressed: () async {
final List<XFile> result = await AdvancedMediaPicker.openPicker(
context: context,
style: PickerStyle(),
cameraStyle: CameraStyle(),
allowedTypes: PickerAssetType.image,
maxVideoDuration: 60,
selectionLimit: 10,
);
print('#result# : $result');
selectedFiles.value = result;
},
),
);
}
}