show method
Future<MediaPickerSelection?>
show(
- BuildContext context, {
- int maxImages = 10,
- MediaPickerLabels? labels,
Implementation
Future<MediaPickerSelection?> show(
BuildContext context, {
int maxImages = 10,
MediaPickerLabels? labels,
}) async {
final mediaStatus = await Permission.photos.status;
if (mediaStatus.isDenied && Platform.isIOS) {
await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Not authorized'),
content: const Text("This app can't have access to user media gallery. You must update authorizations in app settings."),
actions: <Widget>[
OutlinedButton(
style: OutlinedButton.styleFrom(
side: const BorderSide(
color: Colors.transparent,
)),
child: const Text('Open Settings'),
onPressed: () {
openAppSettings();
},
),
],
),
);
} else if (await Permission.storage.request().isGranted &&
(mediaStatus.isGranted ||
await Permission.photos.request().isGranted)) {
final result = await Navigator.push(
context,
MaterialPageRoute(builder: (context) =>
MediaPicker(
labels: labels,
initialSelection:
MediaPickerSelection(types??[MediaType.image, MediaType.video],
maxItems: 10,
),
),
),
);
return result;
}
return null;
}