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

Commit 18474d6

Browse files
committed
[image_picker] add forceFullMetadata to example
1 parent a49b7eb commit 18474d6

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
@@ -107,13 +107,14 @@ class _MyHomePageState extends State<MyHomePage> {
107107
});
108108
} else {
109109
await _displayPickImageDialog(context!,
110-
(double? maxWidth, double? maxHeight, int? quality) async {
110+
(double? maxWidth, double? maxHeight, int? quality, bool forceFullMetadata) async {
111111
try {
112112
final pickedFile = await _picker.pickImage(
113113
source: source,
114114
maxWidth: maxWidth,
115115
maxHeight: maxHeight,
116116
imageQuality: quality,
117+
forceFullMetadata: forceFullMetadata,
117118
);
118119
setState(() {
119120
_imageFile = pickedFile;
@@ -358,60 +359,72 @@ class _MyHomePageState extends State<MyHomePage> {
358359
return showDialog(
359360
context: context,
360361
builder: (context) {
361-
return AlertDialog(
362-
title: Text('Add optional parameters'),
363-
content: Column(
364-
children: <Widget>[
365-
TextField(
366-
controller: maxWidthController,
367-
keyboardType: TextInputType.numberWithOptions(decimal: true),
368-
decoration:
369-
InputDecoration(hintText: "Enter maxWidth if desired"),
370-
),
371-
TextField(
372-
controller: maxHeightController,
373-
keyboardType: TextInputType.numberWithOptions(decimal: true),
374-
decoration:
375-
InputDecoration(hintText: "Enter maxHeight if desired"),
376-
),
377-
TextField(
378-
controller: qualityController,
379-
keyboardType: TextInputType.number,
380-
decoration:
381-
InputDecoration(hintText: "Enter quality if desired"),
382-
),
383-
],
384-
),
385-
actions: <Widget>[
386-
TextButton(
387-
child: const Text('CANCEL'),
388-
onPressed: () {
389-
Navigator.of(context).pop();
390-
},
362+
bool forceFullMetadata = true;
363+
return StatefulBuilder(builder: (context, setState) {
364+
return AlertDialog(
365+
title: Text('Add optional parameters'),
366+
content: Column(
367+
children: <Widget>[
368+
TextField(
369+
controller: maxWidthController,
370+
keyboardType: TextInputType.numberWithOptions(decimal: true),
371+
decoration:
372+
InputDecoration(hintText: "Enter maxWidth if desired"),
373+
),
374+
TextField(
375+
controller: maxHeightController,
376+
keyboardType: TextInputType.numberWithOptions(decimal: true),
377+
decoration:
378+
InputDecoration(hintText: "Enter maxHeight if desired"),
379+
),
380+
TextField(
381+
controller: qualityController,
382+
keyboardType: TextInputType.number,
383+
decoration:
384+
InputDecoration(hintText: "Enter quality if desired"),
385+
),
386+
CheckboxListTile(
387+
value: forceFullMetadata,
388+
onChanged: (bool? value) {
389+
setState(() {
390+
forceFullMetadata = value ?? false;
391+
});
392+
},
393+
title: Text("Force full metadata"),
394+
)
395+
],
391396
),
392-
TextButton(
393-
child: const Text('PICK'),
397+
actions: <Widget>[
398+
TextButton(
399+
child: const Text('CANCEL'),
394400
onPressed: () {
395-
double? width = maxWidthController.text.isNotEmpty
396-
? double.parse(maxWidthController.text)
397-
: null;
398-
double? height = maxHeightController.text.isNotEmpty
399-
? double.parse(maxHeightController.text)
400-
: null;
401-
int? quality = qualityController.text.isNotEmpty
402-
? int.parse(qualityController.text)
403-
: null;
404-
onPick(width, height, quality);
405401
Navigator.of(context).pop();
406-
}),
407-
],
408-
);
402+
},
403+
),
404+
TextButton(
405+
child: const Text('PICK'),
406+
onPressed: () {
407+
double? width = maxWidthController.text.isNotEmpty
408+
? double.parse(maxWidthController.text)
409+
: null;
410+
double? height = maxHeightController.text.isNotEmpty
411+
? double.parse(maxHeightController.text)
412+
: null;
413+
int? quality = qualityController.text.isNotEmpty
414+
? int.parse(qualityController.text)
415+
: null;
416+
onPick(width, height, quality, forceFullMetadata);
417+
Navigator.of(context).pop();
418+
}),
419+
],
420+
);
421+
});
409422
});
410423
}
411424
}
412425

413426
typedef void OnPickImageCallback(
414-
double? maxWidth, double? maxHeight, int? quality);
427+
double? maxWidth, double? maxHeight, int? quality, bool forceFullMetadata);
415428

416429
class AspectRatioVideo extends StatefulWidget {
417430
AspectRatioVideo(this.controller);

0 commit comments

Comments
 (0)