Skip to content

[image_picker] redesign example app #9625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions packages/image_picker/image_picker_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text(widget.title!),
),
body: Center(
body: Align(
alignment: Alignment.topCenter,
child: !kIsWeb && defaultTargetPlatform == TargetPlatform.android
? FutureBuilder<void>(
future: retrieveLostData(),
Expand Down Expand Up @@ -372,20 +373,21 @@ class _MyHomePageState extends State<MyHomePage> {
children: <Widget>[
Semantics(
label: 'image_picker_example_from_gallery',
child: FloatingActionButton(
child: FloatingActionButton.extended(
key: const Key('image_picker_example_from_gallery'),
onPressed: () {
_isVideo = false;
_onImageButtonPressed(ImageSource.gallery, context: context);
},
heroTag: 'image0',
tooltip: 'Pick Image from gallery',
child: const Icon(Icons.photo),
label: const Text('Pick Image from gallery'),
icon: const Icon(Icons.photo),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -397,12 +399,13 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'multipleMedia',
tooltip: 'Pick Multiple Media from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Multiple Media from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -413,12 +416,13 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'media',
tooltip: 'Pick Single Media from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Single Media from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -429,45 +433,49 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'image1',
tooltip: 'Pick Multiple Image from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Multiple Image from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(ImageSource.camera, context: context);
},
heroTag: 'image2',
tooltip: 'Take a Photo',
child: const Icon(Icons.camera_alt),
label: const Text('Take a Photo'),
icon: const Icon(Icons.camera_alt),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
backgroundColor: Colors.red,
onPressed: () {
_isVideo = true;
_onImageButtonPressed(ImageSource.gallery, context: context);
},
heroTag: 'video0',
tooltip: 'Pick Video from gallery',
child: const Icon(Icons.video_library),
label: const Text('Pick Video from gallery'),
icon: const Icon(Icons.video_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
backgroundColor: Colors.red,
onPressed: () {
_isVideo = true;
_onImageButtonPressed(ImageSource.camera, context: context);
},
heroTag: 'video1',
tooltip: 'Take a Video',
child: const Icon(Icons.videocam),
label: const Text('Take a Video'),
icon: const Icon(Icons.videocam),
),
),
],
Expand Down
39 changes: 24 additions & 15 deletions packages/image_picker/image_picker_ios/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,28 +284,31 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text(widget.title!),
),
body: Center(
body: Align(
alignment: Alignment.topCenter,
child: _handlePreview(),
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Semantics(
label: 'image_picker_example_from_gallery',
child: FloatingActionButton(
child: FloatingActionButton.extended(
key: const Key('image_picker_example_from_gallery'),
onPressed: () {
_isVideo = false;
_onImageButtonPressed(ImageSource.gallery, context: context);
},
heroTag: 'image0',
tooltip: 'Pick Image from gallery',
child: const Icon(Icons.photo),
label: const Text('Pick Image from gallery'),
icon: const Icon(Icons.photo),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -317,12 +320,13 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'multipleMedia',
tooltip: 'Pick Multiple Media from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Multiple Media from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -333,12 +337,13 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'media',
tooltip: 'Pick Single Media from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Single Media from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -349,45 +354,49 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'image1',
tooltip: 'Pick Multiple Image from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Multiple Image from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(ImageSource.camera, context: context);
},
heroTag: 'image2',
tooltip: 'Take a Photo',
child: const Icon(Icons.camera_alt),
label: const Text('Take a Photo'),
icon: const Icon(Icons.camera_alt),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
backgroundColor: Colors.red,
onPressed: () {
_isVideo = true;
_onImageButtonPressed(ImageSource.gallery, context: context);
},
heroTag: 'video0',
tooltip: 'Pick Video from gallery',
child: const Icon(Icons.video_library),
label: const Text('Pick Video from gallery'),
icon: const Icon(Icons.video_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
backgroundColor: Colors.red,
onPressed: () {
_isVideo = true;
_onImageButtonPressed(ImageSource.camera, context: context);
},
heroTag: 'video1',
tooltip: 'Take a Video',
child: const Icon(Icons.videocam),
label: const Text('Take a Video'),
icon: const Icon(Icons.videocam),
),
),
],
Expand Down
38 changes: 23 additions & 15 deletions packages/image_picker/image_picker_linux/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,30 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text(widget.title!),
),
body: Center(
body: Align(
alignment: Alignment.topCenter,
child: _handlePreview(),
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Semantics(
label: 'image_picker_example_from_gallery',
child: FloatingActionButton(
child: FloatingActionButton.extended(
key: const Key('image_picker_example_from_gallery'),
onPressed: () {
_isVideo = false;
_onImageButtonPressed(ImageSource.gallery, context: context);
},
heroTag: 'image0',
tooltip: 'Pick Image from gallery',
child: const Icon(Icons.photo),
label: const Text('Pick Image from gallery'),
icon: const Icon(Icons.photo),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -310,12 +312,13 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'multipleMedia',
tooltip: 'Pick Multiple Media from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Multiple Media from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -326,12 +329,13 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'media',
tooltip: 'Pick Single Media from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Single Media from gallery'),
icon: const Icon(Icons.photo_library),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(
Expand All @@ -342,47 +346,51 @@ class _MyHomePageState extends State<MyHomePage> {
},
heroTag: 'image1',
tooltip: 'Pick Multiple Image from gallery',
child: const Icon(Icons.photo_library),
label: const Text('Pick Multiple Image from gallery'),
icon: const Icon(Icons.photo_library),
),
),
if (_picker.supportsImageSource(ImageSource.camera))
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
onPressed: () {
_isVideo = false;
_onImageButtonPressed(ImageSource.camera, context: context);
},
heroTag: 'image2',
tooltip: 'Take a Photo',
child: const Icon(Icons.camera_alt),
label: const Text('Take a Photo'),
icon: const Icon(Icons.camera_alt),
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
backgroundColor: Colors.red,
onPressed: () {
_isVideo = true;
_onImageButtonPressed(ImageSource.gallery, context: context);
},
heroTag: 'video0',
tooltip: 'Pick Video from gallery',
child: const Icon(Icons.video_library),
label: const Text('Pick Video from gallery'),
icon: const Icon(Icons.video_library),
),
),
if (_picker.supportsImageSource(ImageSource.camera))
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: FloatingActionButton(
child: FloatingActionButton.extended(
backgroundColor: Colors.red,
onPressed: () {
_isVideo = true;
_onImageButtonPressed(ImageSource.camera, context: context);
},
heroTag: 'video1',
tooltip: 'Take a Video',
child: const Icon(Icons.videocam),
label: const Text('Take a Video'),
icon: const Icon(Icons.videocam),
),
),
],
Expand Down
Loading