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

[file_selector] initial implementation #3140

Merged
merged 156 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
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 Jul 16, 2020
390c1fe
Add DOM Initialization and Test a[download]
jasonpanelli Jul 17, 2020
234c811
Add FilePicker Type + Add TextField to Example
jasonpanelli Jul 19, 2020
4fd9c14
Test Blob URL Instead of Data Scheme
jasonpanelli Jul 19, 2020
2d06300
Rename PickedFile to XFile; Implement saveFile with Uint8List
jasonpanelli Jul 22, 2020
2d924da
PoC loadFile text only
jasonpanelli Jul 22, 2020
fccf520
Add suggestedName to saveFile
jasonpanelli Jul 22, 2020
0a40194
Use file name in loadFile example
jasonpanelli Jul 23, 2020
30bae1d
Load Multiple Files, Save As a Type
jasonpanelli Jul 24, 2020
06cf4fc
Add Method Channel Implementation + Some Refactor
jasonpanelli Jul 27, 2020
3303db7
Initial Refactor
jasonpanelli Jul 27, 2020
2b21ba4
Basic Method Channel Tests
jasonpanelli Jul 27, 2020
9b7d3fe
Break Down loadFile Into Smaller Parts
jasonpanelli Jul 28, 2020
5f5f9aa
Use FileTypeFilterGroup class
jasonpanelli Jul 28, 2020
a73f088
Bug Fix (No Input to File Extension)
jasonpanelli Jul 28, 2020
e8e9f41
More Refactor of loadFile and saveFile into Smaller Pieces (Prep for …
jasonpanelli Jul 29, 2020
2dc5059
Initial tests for web implementation
jasonpanelli Jul 31, 2020
73c4b62
Delete original test file
jasonpanelli Jul 31, 2020
3b3ab63
Test Loading Multiple Files + saveFile tests
jasonpanelli Aug 1, 2020
d24b55a
Fix Example Text Overflow
jasonpanelli Aug 4, 2020
727c752
Add XPath class and New API to interface
jasonpanelli Aug 4, 2020
d0855d9
Add XPath and begin getReadPath(s)
jasonpanelli Aug 5, 2020
7398fff
Functional getReadPath
jasonpanelli Aug 5, 2020
4eccd88
Do Nothing in getSavePath web
jasonpanelli Aug 5, 2020
c995259
Refactor XFile Class to use XPath
jasonpanelli Aug 5, 2020
dc400aa
Remove XPath, update API
jasonpanelli Aug 10, 2020
2999129
Move Save Logic to XFile and Remove XPath
jasonpanelli Aug 11, 2020
1abe106
Add XType and XTypeGroup
jasonpanelli Aug 17, 2020
52a17fe
Remove Named Constructors
jasonpanelli Aug 17, 2020
ee291fc
Bug Fix, 'accept' attribute requires extensions start with '.'
jasonpanelli Aug 18, 2020
e646680
Rename Filter Group to XType
jasonpanelli Aug 18, 2020
a169c81
Add XType to XFile and Update XFile
jasonpanelli Aug 19, 2020
b22754c
Refactor file_picker to file_selector
jasonpanelli Aug 19, 2020
26457db
Update example app
jasonpanelli Aug 19, 2020
bfc2f6a
Add lastModified with time zone adjustment
jasonpanelli Aug 20, 2020
1538a74
Update API to include non-web supported features
jasonpanelli Aug 20, 2020
bcdc562
Update Example App - Separate load and save
jasonpanelli Aug 20, 2020
1726804
Load Images and Text Files in Example + Bug Fixes
jasonpanelli Aug 21, 2020
0852e94
API tests
jasonpanelli Aug 21, 2020
e558466
Test DOM container and input element creation
jasonpanelli Aug 22, 2020
6d6460c
loadFile, loadFiles, and getSavePath tests
jasonpanelli Aug 24, 2020
ea025a2
XFile saveTo(..) tests
jasonpanelli Aug 24, 2020
8899684
update Method Channel
jasonpanelli Aug 24, 2020
8cc32cc
Enforce txt file in anchor (Example app)
jasonpanelli Aug 25, 2020
1827c99
Accept extensions in web saving
jasonpanelli Aug 25, 2020
228c5de
Include extensions in loadFile
jasonpanelli Aug 25, 2020
1eec76a
Update XTypeGroup to new API
jasonpanelli Aug 26, 2020
b603098
Add confirmButtonText to all functions, acceptedTypeGroups to getSave…
jasonpanelli Aug 27, 2020
014823f
Fix `flutter analyze` issues
jasonpanelli Aug 28, 2020
7677ccd
Update unsupported.dart
jasonpanelli Aug 28, 2020
4d30ca6
Format code
jasonpanelli Aug 28, 2020
861c103
Document all public members
jasonpanelli Aug 28, 2020
c90794e
Move helpers out of XFile class
jasonpanelli Aug 28, 2020
dc76e47
Use simpiler structures in method channels
jasonpanelli Aug 28, 2020
ed83bbb
Change some variables to final
jasonpanelli Aug 28, 2020
eb19648
Assert in constructor initializer list instead of body
jasonpanelli Aug 28, 2020
bd58fe4
Change Error to PlatformException
jasonpanelli Aug 29, 2020
9213f92
Update README.md
jasonpanelli Aug 31, 2020
c072c75
Address Some Comments
jasonpanelli Sep 1, 2020
47eb130
Merge pull request #1 from flutter/master
jasonpanelli Sep 1, 2020
38a7ea0
"Hello World" file_picker plugin
jasonpanelli Jul 16, 2020
23365e1
Add DOM Initialization and Test a[download]
jasonpanelli Jul 17, 2020
59a3bda
Add FilePicker Type + Add TextField to Example
jasonpanelli Jul 19, 2020
6ea58cd
Test Blob URL Instead of Data Scheme
jasonpanelli Jul 19, 2020
95c97df
Rename PickedFile to XFile; Implement saveFile with Uint8List
jasonpanelli Jul 22, 2020
1cbde02
PoC loadFile text only
jasonpanelli Jul 22, 2020
312d53f
Add suggestedName to saveFile
jasonpanelli Jul 22, 2020
58ae8a5
Use file name in loadFile example
jasonpanelli Jul 23, 2020
ba80aae
Load Multiple Files, Save As a Type
jasonpanelli Jul 24, 2020
1b14104
Add Method Channel Implementation + Some Refactor
jasonpanelli Jul 27, 2020
5880089
Initial Refactor
jasonpanelli Jul 27, 2020
d29afa2
Basic Method Channel Tests
jasonpanelli Jul 27, 2020
49fe0b8
Break Down loadFile Into Smaller Parts
jasonpanelli Jul 28, 2020
5d6bec0
Use FileTypeFilterGroup class
jasonpanelli Jul 28, 2020
1a8a928
Bug Fix (No Input to File Extension)
jasonpanelli Jul 28, 2020
80d4dbd
More Refactor of loadFile and saveFile into Smaller Pieces (Prep for …
jasonpanelli Jul 29, 2020
a023938
Initial tests for web implementation
jasonpanelli Jul 31, 2020
b0f31c3
Delete original test file
jasonpanelli Jul 31, 2020
fe2265c
Test Loading Multiple Files + saveFile tests
jasonpanelli Aug 1, 2020
53bea28
Fix Example Text Overflow
jasonpanelli Aug 4, 2020
f1383ea
Add XPath class and New API to interface
jasonpanelli Aug 4, 2020
d879cc3
Add XPath and begin getReadPath(s)
jasonpanelli Aug 5, 2020
8d13d4d
Functional getReadPath
jasonpanelli Aug 5, 2020
f600526
Do Nothing in getSavePath web
jasonpanelli Aug 5, 2020
c65cede
Refactor XFile Class to use XPath
jasonpanelli Aug 5, 2020
2f5e62f
Remove XPath, update API
jasonpanelli Aug 10, 2020
7b2237e
Move Save Logic to XFile and Remove XPath
jasonpanelli Aug 11, 2020
15e9252
Add XType and XTypeGroup
jasonpanelli Aug 17, 2020
0aa471c
Remove Named Constructors
jasonpanelli Aug 17, 2020
48adaee
Bug Fix, 'accept' attribute requires extensions start with '.'
jasonpanelli Aug 18, 2020
6a586dc
Rename Filter Group to XType
jasonpanelli Aug 18, 2020
6b3e749
Add XType to XFile and Update XFile
jasonpanelli Aug 19, 2020
62ddfdf
Refactor file_picker to file_selector
jasonpanelli Aug 19, 2020
12bd4c0
Update example app
jasonpanelli Aug 19, 2020
9751240
Add lastModified with time zone adjustment
jasonpanelli Aug 20, 2020
549bcee
Update API to include non-web supported features
jasonpanelli Aug 20, 2020
c7eea58
Update Example App - Separate load and save
jasonpanelli Aug 20, 2020
2cf24c1
Load Images and Text Files in Example + Bug Fixes
jasonpanelli Aug 21, 2020
ad4a5e7
API tests
jasonpanelli Aug 21, 2020
155bb08
Test DOM container and input element creation
jasonpanelli Aug 22, 2020
19d1e47
loadFile, loadFiles, and getSavePath tests
jasonpanelli Aug 24, 2020
bbe56f1
XFile saveTo(..) tests
jasonpanelli Aug 24, 2020
2440e1c
update Method Channel
jasonpanelli Aug 24, 2020
7425f72
Enforce txt file in anchor (Example app)
jasonpanelli Aug 25, 2020
884eb1d
Accept extensions in web saving
jasonpanelli Aug 25, 2020
7075265
Include extensions in loadFile
jasonpanelli Aug 25, 2020
05fafbd
Update XTypeGroup to new API
jasonpanelli Aug 26, 2020
3e6063f
Add confirmButtonText to all functions, acceptedTypeGroups to getSave…
jasonpanelli Aug 27, 2020
e97182d
Fix `flutter analyze` issues
jasonpanelli Aug 28, 2020
a1bc749
Update unsupported.dart
jasonpanelli Aug 28, 2020
f58d402
Format code
jasonpanelli Aug 28, 2020
73d81a1
Document all public members
jasonpanelli Aug 28, 2020
83acae0
Move helpers out of XFile class
jasonpanelli Aug 28, 2020
70cc825
Use simpiler structures in method channels
jasonpanelli Aug 28, 2020
415706c
Change some variables to final
jasonpanelli Aug 28, 2020
08d86e9
Assert in constructor initializer list instead of body
jasonpanelli Aug 28, 2020
8a30f6d
Change Error to PlatformException
jasonpanelli Aug 29, 2020
b855b1c
Update README.md
jasonpanelli Aug 31, 2020
ade07e4
Address Some Comments
jasonpanelli Sep 1, 2020
bbd5dc2
Merge branch 'file_picker' of https://github.com/jasonpanelli/plugins…
jasonpanelli Sep 1, 2020
438831d
Move e2e tests to integration_test
jasonpanelli Sep 1, 2020
7daf109
Rename e2e files and update test/README
jasonpanelli Sep 2, 2020
67005aa
Check for empty XTypeGroup and use lastModified instead of lastModifi…
jasonpanelli Sep 2, 2020
50c4ea2
Change load to open
jasonpanelli Sep 2, 2020
67bd59c
Add getDirectoryPath
jasonpanelli Sep 2, 2020
19ca49c
Some files still referred to file_picker
jasonpanelli Sep 2, 2020
f694426
Remove TODO
jasonpanelli Sep 3, 2020
8a2c11e
Update platform interface
jasonpanelli Sep 4, 2020
cc29898
Update Coprights
jasonpanelli Sep 4, 2020
0a3732c
Add XTypeGroup tests and remove document/* as a web wild card
jasonpanelli Sep 8, 2020
1378914
Update Licenses
jasonpanelli Sep 8, 2020
5f144df
Removes file_selector_platform_interface and file_selector_web
tugorez Oct 11, 2020
11a4d74
Removes file_selector example folder.
tugorez Oct 11, 2020
288e46e
Fix pubspec
tugorez Oct 12, 2020
2e7f3a7
Merge branch 'master' into file_selector
tugorez Oct 12, 2020
d644c44
Fix CHANGELOG
tugorez Oct 12, 2020
725dbc5
Restore example folder
tugorez Oct 13, 2020
42852c2
Change example styles
tugorez Oct 13, 2020
ece9ef2
Removes example's tests folder
tugorez Oct 13, 2020
67afdb5
Change version
tugorez Oct 16, 2020
e4ed98d
Change version to 0.7.0
tugorez Oct 22, 2020
8917116
Improve the Readme template
tugorez Oct 23, 2020
1c2c956
Improve the example's Readme template
tugorez Oct 23, 2020
422f1b4
Improves the README
tugorez Oct 23, 2020
4b09ffc
Improve the README
tugorez Oct 23, 2020
9dc80ba
Revamp example
tugorez Oct 30, 2020
8e98c95
Improve tests
tugorez Oct 30, 2020
e907949
Merge branch 'master' into file_selector
tugorez Oct 30, 2020
4d8bd68
Add open multiple images example
tugorez Oct 30, 2020
2284daa
Add documentation to public field
tugorez Oct 30, 2020
208e504
Add get directory example
tugorez Nov 6, 2020
5a0c109
Merge branch 'master' into file_selector
tugorez Nov 6, 2020
3d2cf35
Improve tests
tugorez Nov 16, 2020
113c756
Fix the example's class comments
tugorez Nov 20, 2020
8fb1fcc
Change button's label
tugorez Nov 20, 2020
ea11561
Address nits
tugorez Nov 20, 2020
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
3 changes: 3 additions & 0 deletions packages/file_selector/file_selector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.7.0

* Initial Open Source release.
25 changes: 25 additions & 0 deletions packages/file_selector/file_selector/LICENSE
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.
36 changes: 36 additions & 0 deletions packages/file_selector/file_selector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# file_selector

[![pub package](https://img.shields.io/pub/v/file_selector.svg)](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
48 changes: 48 additions & 0 deletions packages/file_selector/file_selector/example/.gitignore
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
10 changes: 10 additions & 0 deletions packages/file_selector/file_selector/example/.metadata
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
8 changes: 8 additions & 0 deletions packages/file_selector/file_selector/example/README.md
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 packages/file_selector/file_selector/example/lib/home_page.dart
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 packages/file_selector/file_selector/example/lib/main.dart
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(),
},
);
}
}
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);
},
),
],
);
}
}
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',
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

extensions: ['jpg', 'jpeg'],
);
final XTypeGroup pngTypeGroup = XTypeGroup(
extensions: ['png'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no label?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
},
),
],
);
}
}
Loading