Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 7c1716b

Browse files
committed
[image_picker] add forceFullMetadata to example
1 parent d22082a commit 7c1716b

File tree

1 file changed

+60
-47
lines changed
  • packages/image_picker/image_picker/example/lib

1 file changed

+60
-47
lines changed

packages/image_picker/image_picker/example/lib/main.dart

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ class _MyHomePageState extends State<MyHomePage> {
8585
await _playVideo(file);
8686
} else {
8787
await _displayPickImageDialog(context!,
88-
(double? maxWidth, double? maxHeight, int? quality) async {
88+
(double? maxWidth, double? maxHeight, int? quality, bool forceFullMetadata) async {
8989
try {
9090
final pickedFile = await _picker.getImage(
9191
source: source,
9292
maxWidth: maxWidth,
9393
maxHeight: maxHeight,
9494
imageQuality: quality,
95+
forceFullMetadata: forceFullMetadata,
9596
);
9697
setState(() {
9798
_imageFile = pickedFile;
@@ -305,60 +306,72 @@ class _MyHomePageState extends State<MyHomePage> {
305306
return showDialog(
306307
context: context,
307308
builder: (context) {
308-
return AlertDialog(
309-
title: Text('Add optional parameters'),
310-
content: Column(
311-
children: <Widget>[
312-
TextField(
313-
controller: maxWidthController,
314-
keyboardType: TextInputType.numberWithOptions(decimal: true),
315-
decoration:
316-
InputDecoration(hintText: "Enter maxWidth if desired"),
317-
),
318-
TextField(
319-
controller: maxHeightController,
320-
keyboardType: TextInputType.numberWithOptions(decimal: true),
321-
decoration:
322-
InputDecoration(hintText: "Enter maxHeight if desired"),
323-
),
324-
TextField(
325-
controller: qualityController,
326-
keyboardType: TextInputType.number,
327-
decoration:
328-
InputDecoration(hintText: "Enter quality if desired"),
329-
),
330-
],
331-
),
332-
actions: <Widget>[
333-
TextButton(
334-
child: const Text('CANCEL'),
335-
onPressed: () {
336-
Navigator.of(context).pop();
337-
},
309+
bool forceFullMetadata = true;
310+
return StatefulBuilder(builder: (context, setState) {
311+
return AlertDialog(
312+
title: Text('Add optional parameters'),
313+
content: Column(
314+
children: <Widget>[
315+
TextField(
316+
controller: maxWidthController,
317+
keyboardType: TextInputType.numberWithOptions(decimal: true),
318+
decoration:
319+
InputDecoration(hintText: "Enter maxWidth if desired"),
320+
),
321+
TextField(
322+
controller: maxHeightController,
323+
keyboardType: TextInputType.numberWithOptions(decimal: true),
324+
decoration:
325+
InputDecoration(hintText: "Enter maxHeight if desired"),
326+
),
327+
TextField(
328+
controller: qualityController,
329+
keyboardType: TextInputType.number,
330+
decoration:
331+
InputDecoration(hintText: "Enter quality if desired"),
332+
),
333+
CheckboxListTile(
334+
value: forceFullMetadata,
335+
onChanged: (bool? value) {
336+
setState(() {
337+
forceFullMetadata = value ?? false;
338+
});
339+
},
340+
title: Text("Force full metadata"),
341+
)
342+
],
338343
),
339-
TextButton(
340-
child: const Text('PICK'),
344+
actions: <Widget>[
345+
TextButton(
346+
child: const Text('CANCEL'),
341347
onPressed: () {
342-
double? width = maxWidthController.text.isNotEmpty
343-
? double.parse(maxWidthController.text)
344-
: null;
345-
double? height = maxHeightController.text.isNotEmpty
346-
? double.parse(maxHeightController.text)
347-
: null;
348-
int? quality = qualityController.text.isNotEmpty
349-
? int.parse(qualityController.text)
350-
: null;
351-
onPick(width, height, quality);
352348
Navigator.of(context).pop();
353-
}),
354-
],
355-
);
349+
},
350+
),
351+
TextButton(
352+
child: const Text('PICK'),
353+
onPressed: () {
354+
double? width = maxWidthController.text.isNotEmpty
355+
? double.parse(maxWidthController.text)
356+
: null;
357+
double? height = maxHeightController.text.isNotEmpty
358+
? double.parse(maxHeightController.text)
359+
: null;
360+
int? quality = qualityController.text.isNotEmpty
361+
? int.parse(qualityController.text)
362+
: null;
363+
onPick(width, height, quality, forceFullMetadata);
364+
Navigator.of(context).pop();
365+
}),
366+
],
367+
);
368+
});
356369
});
357370
}
358371
}
359372

360373
typedef void OnPickImageCallback(
361-
double? maxWidth, double? maxHeight, int? quality);
374+
double? maxWidth, double? maxHeight, int? quality, bool forceFullMetadata);
362375

363376
class AspectRatioVideo extends StatefulWidget {
364377
AspectRatioVideo(this.controller);

0 commit comments

Comments
 (0)