This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[file_selector] initial implementation #3140
Merged
Merged
Changes from 150 commits
Commits
Show all changes
156 commits
Select commit
Hold shift + click to select a range
ec70f70
"Hello World" file_picker plugin
jasonpanelli 390c1fe
Add DOM Initialization and Test a[download]
jasonpanelli 234c811
Add FilePicker Type + Add TextField to Example
jasonpanelli 4fd9c14
Test Blob URL Instead of Data Scheme
jasonpanelli 2d06300
Rename PickedFile to XFile; Implement saveFile with Uint8List
jasonpanelli 2d924da
PoC loadFile text only
jasonpanelli fccf520
Add suggestedName to saveFile
jasonpanelli 0a40194
Use file name in loadFile example
jasonpanelli 30bae1d
Load Multiple Files, Save As a Type
jasonpanelli 06cf4fc
Add Method Channel Implementation + Some Refactor
jasonpanelli 3303db7
Initial Refactor
jasonpanelli 2b21ba4
Basic Method Channel Tests
jasonpanelli 9b7d3fe
Break Down loadFile Into Smaller Parts
jasonpanelli 5f5f9aa
Use FileTypeFilterGroup class
jasonpanelli a73f088
Bug Fix (No Input to File Extension)
jasonpanelli e8e9f41
More Refactor of loadFile and saveFile into Smaller Pieces (Prep for …
jasonpanelli 2dc5059
Initial tests for web implementation
jasonpanelli 73c4b62
Delete original test file
jasonpanelli 3b3ab63
Test Loading Multiple Files + saveFile tests
jasonpanelli d24b55a
Fix Example Text Overflow
jasonpanelli 727c752
Add XPath class and New API to interface
jasonpanelli d0855d9
Add XPath and begin getReadPath(s)
jasonpanelli 7398fff
Functional getReadPath
jasonpanelli 4eccd88
Do Nothing in getSavePath web
jasonpanelli c995259
Refactor XFile Class to use XPath
jasonpanelli dc400aa
Remove XPath, update API
jasonpanelli 2999129
Move Save Logic to XFile and Remove XPath
jasonpanelli 1abe106
Add XType and XTypeGroup
jasonpanelli 52a17fe
Remove Named Constructors
jasonpanelli ee291fc
Bug Fix, 'accept' attribute requires extensions start with '.'
jasonpanelli e646680
Rename Filter Group to XType
jasonpanelli a169c81
Add XType to XFile and Update XFile
jasonpanelli b22754c
Refactor file_picker to file_selector
jasonpanelli 26457db
Update example app
jasonpanelli bfc2f6a
Add lastModified with time zone adjustment
jasonpanelli 1538a74
Update API to include non-web supported features
jasonpanelli bcdc562
Update Example App - Separate load and save
jasonpanelli 1726804
Load Images and Text Files in Example + Bug Fixes
jasonpanelli 0852e94
API tests
jasonpanelli e558466
Test DOM container and input element creation
jasonpanelli 6d6460c
loadFile, loadFiles, and getSavePath tests
jasonpanelli ea025a2
XFile saveTo(..) tests
jasonpanelli 8899684
update Method Channel
jasonpanelli 8cc32cc
Enforce txt file in anchor (Example app)
jasonpanelli 1827c99
Accept extensions in web saving
jasonpanelli 228c5de
Include extensions in loadFile
jasonpanelli 1eec76a
Update XTypeGroup to new API
jasonpanelli b603098
Add confirmButtonText to all functions, acceptedTypeGroups to getSave…
jasonpanelli 014823f
Fix `flutter analyze` issues
jasonpanelli 7677ccd
Update unsupported.dart
jasonpanelli 4d30ca6
Format code
jasonpanelli 861c103
Document all public members
jasonpanelli c90794e
Move helpers out of XFile class
jasonpanelli dc76e47
Use simpiler structures in method channels
jasonpanelli ed83bbb
Change some variables to final
jasonpanelli eb19648
Assert in constructor initializer list instead of body
jasonpanelli bd58fe4
Change Error to PlatformException
jasonpanelli 9213f92
Update README.md
jasonpanelli c072c75
Address Some Comments
jasonpanelli 47eb130
Merge pull request #1 from flutter/master
jasonpanelli 38a7ea0
"Hello World" file_picker plugin
jasonpanelli 23365e1
Add DOM Initialization and Test a[download]
jasonpanelli 59a3bda
Add FilePicker Type + Add TextField to Example
jasonpanelli 6ea58cd
Test Blob URL Instead of Data Scheme
jasonpanelli 95c97df
Rename PickedFile to XFile; Implement saveFile with Uint8List
jasonpanelli 1cbde02
PoC loadFile text only
jasonpanelli 312d53f
Add suggestedName to saveFile
jasonpanelli 58ae8a5
Use file name in loadFile example
jasonpanelli ba80aae
Load Multiple Files, Save As a Type
jasonpanelli 1b14104
Add Method Channel Implementation + Some Refactor
jasonpanelli 5880089
Initial Refactor
jasonpanelli d29afa2
Basic Method Channel Tests
jasonpanelli 49fe0b8
Break Down loadFile Into Smaller Parts
jasonpanelli 5d6bec0
Use FileTypeFilterGroup class
jasonpanelli 1a8a928
Bug Fix (No Input to File Extension)
jasonpanelli 80d4dbd
More Refactor of loadFile and saveFile into Smaller Pieces (Prep for …
jasonpanelli a023938
Initial tests for web implementation
jasonpanelli b0f31c3
Delete original test file
jasonpanelli fe2265c
Test Loading Multiple Files + saveFile tests
jasonpanelli 53bea28
Fix Example Text Overflow
jasonpanelli f1383ea
Add XPath class and New API to interface
jasonpanelli d879cc3
Add XPath and begin getReadPath(s)
jasonpanelli 8d13d4d
Functional getReadPath
jasonpanelli f600526
Do Nothing in getSavePath web
jasonpanelli c65cede
Refactor XFile Class to use XPath
jasonpanelli 2f5e62f
Remove XPath, update API
jasonpanelli 7b2237e
Move Save Logic to XFile and Remove XPath
jasonpanelli 15e9252
Add XType and XTypeGroup
jasonpanelli 0aa471c
Remove Named Constructors
jasonpanelli 48adaee
Bug Fix, 'accept' attribute requires extensions start with '.'
jasonpanelli 6a586dc
Rename Filter Group to XType
jasonpanelli 6b3e749
Add XType to XFile and Update XFile
jasonpanelli 62ddfdf
Refactor file_picker to file_selector
jasonpanelli 12bd4c0
Update example app
jasonpanelli 9751240
Add lastModified with time zone adjustment
jasonpanelli 549bcee
Update API to include non-web supported features
jasonpanelli c7eea58
Update Example App - Separate load and save
jasonpanelli 2cf24c1
Load Images and Text Files in Example + Bug Fixes
jasonpanelli ad4a5e7
API tests
jasonpanelli 155bb08
Test DOM container and input element creation
jasonpanelli 19d1e47
loadFile, loadFiles, and getSavePath tests
jasonpanelli bbe56f1
XFile saveTo(..) tests
jasonpanelli 2440e1c
update Method Channel
jasonpanelli 7425f72
Enforce txt file in anchor (Example app)
jasonpanelli 884eb1d
Accept extensions in web saving
jasonpanelli 7075265
Include extensions in loadFile
jasonpanelli 05fafbd
Update XTypeGroup to new API
jasonpanelli 3e6063f
Add confirmButtonText to all functions, acceptedTypeGroups to getSave…
jasonpanelli e97182d
Fix `flutter analyze` issues
jasonpanelli a1bc749
Update unsupported.dart
jasonpanelli f58d402
Format code
jasonpanelli 73d81a1
Document all public members
jasonpanelli 83acae0
Move helpers out of XFile class
jasonpanelli 70cc825
Use simpiler structures in method channels
jasonpanelli 415706c
Change some variables to final
jasonpanelli 08d86e9
Assert in constructor initializer list instead of body
jasonpanelli 8a30f6d
Change Error to PlatformException
jasonpanelli b855b1c
Update README.md
jasonpanelli ade07e4
Address Some Comments
jasonpanelli bbd5dc2
Merge branch 'file_picker' of https://github.com/jasonpanelli/plugins…
jasonpanelli 438831d
Move e2e tests to integration_test
jasonpanelli 7daf109
Rename e2e files and update test/README
jasonpanelli 67005aa
Check for empty XTypeGroup and use lastModified instead of lastModifi…
jasonpanelli 50c4ea2
Change load to open
jasonpanelli 67bd59c
Add getDirectoryPath
jasonpanelli 19ca49c
Some files still referred to file_picker
jasonpanelli f694426
Remove TODO
jasonpanelli 8a2c11e
Update platform interface
jasonpanelli cc29898
Update Coprights
jasonpanelli 0a3732c
Add XTypeGroup tests and remove document/* as a web wild card
jasonpanelli 1378914
Update Licenses
jasonpanelli 5f144df
Removes file_selector_platform_interface and file_selector_web
tugorez 11a4d74
Removes file_selector example folder.
tugorez 288e46e
Fix pubspec
tugorez 2e7f3a7
Merge branch 'master' into file_selector
tugorez d644c44
Fix CHANGELOG
tugorez 725dbc5
Restore example folder
tugorez 42852c2
Change example styles
tugorez ece9ef2
Removes example's tests folder
tugorez 67afdb5
Change version
tugorez e4ed98d
Change version to 0.7.0
tugorez 8917116
Improve the Readme template
tugorez 1c2c956
Improve the example's Readme template
tugorez 422f1b4
Improves the README
tugorez 4b09ffc
Improve the README
tugorez 9dc80ba
Revamp example
tugorez 8e98c95
Improve tests
tugorez e907949
Merge branch 'master' into file_selector
tugorez 4d8bd68
Add open multiple images example
tugorez 2284daa
Add documentation to public field
tugorez 208e504
Add get directory example
tugorez 5a0c109
Merge branch 'master' into file_selector
tugorez 3d2cf35
Improve tests
tugorez 113c756
Fix the example's class comments
tugorez 8fb1fcc
Change button's label
tugorez ea11561
Address nits
tugorez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.7.0 | ||
|
||
* Initial Open Source release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright 2020 The Flutter Authors. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# file_selector | ||
|
||
[](https://pub.dartlang.org/packages/file_selector) | ||
|
||
A Flutter plugin that manages files and interactions with file dialogs. | ||
|
||
## Usage | ||
To use this plugin, add `file_selector` as a [dependency in your pubspec.yaml file](https://flutter.dev/platform-plugins/). | ||
|
||
### Examples | ||
Here are small examples that show you how to use the API. | ||
Please also take a look at our [example][example] app. | ||
|
||
#### Open a single file | ||
``` dart | ||
final typeGroup = XTypeGroup(label: 'images', extensions: ['jpg', 'png']); | ||
final file = await openFile(acceptedTypeGroups: [typeGroup]); | ||
``` | ||
|
||
#### Open multiple files at once | ||
``` dart | ||
final typeGroup = XTypeGroup(label: 'images', extensions: ['jpg', 'png']); | ||
final files = await openFiles(acceptedTypeGroups: [typeGroup]); | ||
``` | ||
|
||
#### Saving a file | ||
```dart | ||
final path = await getSavePath(); | ||
final name = "hello_file_selector.txt"; | ||
final data = Uint8List.fromList("Hello World!".codeUnits); | ||
final mimeType = "text/plain"; | ||
final file = XFile.fromData(data, name: name, mimeType: mimeType); | ||
await file.saveTo(path); | ||
``` | ||
|
||
[example]:./example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Currently only web supported | ||
android/ | ||
ios/ | ||
|
||
# Exceptions to above rules. | ||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 7736f3bc90270dcb0480db2ccffbf1d13c28db85 | ||
channel: dev | ||
|
||
project_type: app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# file_selector_example | ||
|
||
Demonstrates how to use the file_selector plugin. | ||
|
||
## Getting Started | ||
|
||
For help getting started with Flutter, view our online | ||
[documentation](https://flutter.dev/). |
47 changes: 47 additions & 0 deletions
47
packages/file_selector/file_selector/example/lib/home_page.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// Home Page of the application | ||
class HomePage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('File Selector Demo Home Page'), | ||
), | ||
body: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
RaisedButton( | ||
color: Colors.blue, | ||
textColor: Colors.white, | ||
child: Text('Open a text file'), | ||
onPressed: () => Navigator.pushNamed(context, '/open/text'), | ||
), | ||
SizedBox(height: 10), | ||
RaisedButton( | ||
color: Colors.blue, | ||
textColor: Colors.white, | ||
child: Text('Open an image'), | ||
onPressed: () => Navigator.pushNamed(context, '/open/image'), | ||
), | ||
SizedBox(height: 10), | ||
RaisedButton( | ||
color: Colors.blue, | ||
textColor: Colors.white, | ||
child: Text('Open multiple images'), | ||
onPressed: () => Navigator.pushNamed(context, '/open/images'), | ||
), | ||
SizedBox(height: 10), | ||
RaisedButton( | ||
color: Colors.blue, | ||
textColor: Colors.white, | ||
child: Text('Save text into a file'), | ||
onPressed: () => Navigator.pushNamed(context, '/save/text'), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/file_selector/file_selector/example/lib/main.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:example/home_page.dart'; | ||
import 'package:example/save_text_page.dart'; | ||
import 'package:example/open_text_page.dart'; | ||
import 'package:example/open_image_page.dart'; | ||
import 'package:example/open_multiple_images_page.dart'; | ||
|
||
void main() { | ||
runApp(MyApp()); | ||
} | ||
|
||
/// MyApp is the Main Application | ||
class MyApp extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'File Selector Demo', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
visualDensity: VisualDensity.adaptivePlatformDensity, | ||
), | ||
home: HomePage(), | ||
routes: { | ||
'/save/text': (context) => SaveTextPage(), | ||
'/open/text': (context) => OpenTextPage(), | ||
'/open/image': (context) => OpenImagePage(), | ||
'/open/images': (context) => OpenMultipleImagesPage(), | ||
}, | ||
); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
packages/file_selector/file_selector/example/lib/open_image_page.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'dart:io'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:file_selector/file_selector.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
/// Screen that shows an example of openFile(s) | ||
class OpenImagePage extends StatelessWidget { | ||
void _openImageFile(BuildContext context) async { | ||
final XTypeGroup typeGroup = XTypeGroup( | ||
label: 'images', | ||
extensions: ['jpg', 'png'], | ||
); | ||
final List<XFile> files = await openFiles(acceptedTypeGroups: [typeGroup]); | ||
final XFile file = files[0]; | ||
final String fileName = file.name; | ||
final String filePath = file.path; | ||
|
||
await showDialog( | ||
context: context, | ||
builder: (context) => ImageDisplay(fileName, filePath), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text("Open an image"), | ||
), | ||
body: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
RaisedButton( | ||
color: Colors.blue, | ||
textColor: Colors.white, | ||
child: Text('Press to open an image file(png, jpg)'), | ||
onPressed: () => _openImageFile(context), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
/// Widget that displays a text file in a dialog | ||
class ImageDisplay extends StatelessWidget { | ||
/// Image's name | ||
final String fileName; | ||
|
||
/// Image's path | ||
final String filePath; | ||
|
||
/// Default Constructor | ||
ImageDisplay(this.fileName, this.filePath); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AlertDialog( | ||
title: Text(fileName), | ||
// On web the filePath is a blob url | ||
// while on other platforms it is a system path. | ||
content: kIsWeb ? Image.network(filePath) : Image.file(File(filePath)), | ||
actions: [ | ||
FlatButton( | ||
child: const Text('Close'), | ||
onPressed: () { | ||
Navigator.pop(context); | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
packages/file_selector/file_selector/example/lib/open_multiple_images_page.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import 'dart:io'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:file_selector/file_selector.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
/// Screen that shows an example of openFile(s) | ||
class OpenMultipleImagesPage extends StatelessWidget { | ||
void _openImageFile(BuildContext context) async { | ||
final XTypeGroup jpgsTypeGroup = XTypeGroup( | ||
label: 'images', | ||
extensions: ['jpg', 'jpeg'], | ||
); | ||
final XTypeGroup pngTypeGroup = XTypeGroup( | ||
extensions: ['png'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why no label? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
); | ||
final List<XFile> files = await openFiles(acceptedTypeGroups: [ | ||
jpgsTypeGroup, | ||
pngTypeGroup, | ||
]); | ||
await showDialog( | ||
context: context, | ||
builder: (context) => MultipleImagesDisplay(files), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text("Open multiple images"), | ||
), | ||
body: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
RaisedButton( | ||
color: Colors.blue, | ||
textColor: Colors.white, | ||
child: Text('Press to open multiple images (png, jpg)'), | ||
onPressed: () => _openImageFile(context), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
/// Widget that displays a text file in a dialog | ||
class MultipleImagesDisplay extends StatelessWidget { | ||
/// The files containing the images | ||
final List<XFile> files; | ||
|
||
/// Default Constructor | ||
MultipleImagesDisplay(this.files); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AlertDialog( | ||
title: Text('Gallery'), | ||
// On web the filePath is a blob url | ||
// while on other platforms it is a system path. | ||
content: Center( | ||
child: Row( | ||
children: <Widget>[ | ||
...files.map( | ||
(file) => Flexible( | ||
child: kIsWeb | ||
? Image.network(file.path) | ||
: Image.file(File(file.path))), | ||
) | ||
], | ||
), | ||
), | ||
actions: [ | ||
FlatButton( | ||
child: const Text('Close'), | ||
onPressed: () { | ||
Navigator.pop(context); | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems odd to call this "images" rather than "JPEGs" given that the other option is also an image type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!