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.6k
[file_selector] Add Windows support #4424
Merged
fluttergithubbot
merged 25 commits into
flutter-team-archive:main
from
stuartmorgan-g:file-selector-windows
Jan 26, 2022
Merged
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
31ffa90
Initial copy directly from FDE
stuartmorgan-g c0fbde3
Duplicate macOS example, and replace the macos/ boilerplate with wind…
stuartmorgan-g e2dcf5f
Extract the plugin class into its own files
stuartmorgan-g b0c1f49
Placeholder tests
stuartmorgan-g e760f00
Refactor for testability
stuartmorgan-g d81ac0c
Real tests
stuartmorgan-g 1c2beff
CHANGELOG
stuartmorgan-g 031aa60
Exclude integration test
stuartmorgan-g 44d35cf
Remove template-generated analysis options
stuartmorgan-g 698936c
Add AUTHORS
stuartmorgan-g e49ba48
Missing licenses in template code
stuartmorgan-g 27a9425
More formatting
stuartmorgan-g a36d5d5
Fix directory test
stuartmorgan-g 1685aa5
pubspec fixes
stuartmorgan-g a52837a
Merge branch 'master' into file-selector-windows
stuartmorgan-g 5c715a4
Merge branch 'main' into file-selector-windows
stuartmorgan-g 55f8826
Minor fixes
stuartmorgan-g 2219023
Fix publish warning
stuartmorgan-g d67e159
Update build for repo changes
stuartmorgan-g 401af26
Merge branch 'main' into file-selector-windows
stuartmorgan-g 53348b8
Review comments
stuartmorgan-g 6de2ea5
Fix pointer aligments
stuartmorgan-g 24ba33e
Fix bug in single-file example
stuartmorgan-g 2e9d23b
Switch to internal method channel
stuartmorgan-g 8f17b22
Add cross_file to deps
stuartmorgan-g 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
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,5 @@ | ||
| .dart_tool | ||
| .packages | ||
| .flutter-plugins | ||
| .flutter-plugins-dependencies | ||
| pubspec.lock |
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: 6d1c244b79f3a2747281f718297ce248bd5ad099 | ||
| channel: master | ||
|
|
||
| project_type: plugin |
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,6 @@ | ||
| # Below is a list of people and organizations that have contributed | ||
| # to the Flutter project. Names should be added to the list like so: | ||
| # | ||
| # Name/Organization <email address> | ||
|
|
||
| Google Inc. |
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,15 @@ | ||
| ## 0.8.2 | ||
|
|
||
| * Moves source to flutter/plugins, and restructures to allow for unit testing. | ||
|
|
||
| ## 0.0.2+1 | ||
|
|
||
| * Update README | ||
|
|
||
| ## 0.0.2 | ||
|
|
||
| * Update SDK constraint to signal compatibility with null safety. | ||
|
|
||
| ## 0.0.1 | ||
|
|
||
| * Initial Windows implementation of `file_selector`. |
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 2013 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,19 @@ | ||
| # file\_selector\_windows | ||
|
|
||
| The Windows implementation of [`file_selector`][1]. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Importing the package | ||
|
|
||
| This implementation has not yet been endorsed, meaning that you need to | ||
| [depend on `file_selector_windows`][2] in addition to | ||
| [depending on `file_selector`][3]. | ||
|
|
||
| Once your pubspec includes the Windows implementation, you can use the | ||
| `file_selector` APIs normally. You should not use the `file_selector_windows` | ||
| APIs directly. | ||
|
|
||
| [1]: https://pub.dev/packages/file_selector | ||
| [2]: https://pub.dev/packages/file_selector_windows/install | ||
| [3]: https://pub.dev/packages/file_selector/install |
48 changes: 48 additions & 0 deletions
48
packages/file_selector/file_selector_windows/example/.gitignore
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 |
10 changes: 10 additions & 0 deletions
10
packages/file_selector/file_selector_windows/example/.metadata
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 |
4 changes: 4 additions & 0 deletions
4
packages/file_selector/file_selector_windows/example/README.md
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,4 @@ | ||
| # `file_selector_windows` Example | ||
|
|
||
| Demonstrates Windows implementation of the | ||
| [`file_selector` plugin](https://pub.dev/packages/file_selector). |
76 changes: 76 additions & 0 deletions
76
packages/file_selector/file_selector_windows/example/lib/get_directory_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,76 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:file_selector_platform_interface/file_selector_platform_interface.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| /// Screen that shows an example of getDirectoryPath | ||
| class GetDirectoryPage extends StatelessWidget { | ||
| Future<void> _getDirectoryPath(BuildContext context) async { | ||
| const String confirmButtonText = 'Choose'; | ||
| final String? directoryPath = | ||
| await FileSelectorPlatform.instance.getDirectoryPath( | ||
| confirmButtonText: confirmButtonText, | ||
| ); | ||
| if (directoryPath == null) { | ||
| // Operation was canceled by the user. | ||
| return; | ||
| } | ||
| await showDialog<void>( | ||
| context: context, | ||
| builder: (BuildContext context) => TextDisplay(directoryPath), | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| appBar: AppBar( | ||
| title: const Text('Open a text file'), | ||
| ), | ||
| body: Center( | ||
| child: Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: <Widget>[ | ||
| ElevatedButton( | ||
| style: ElevatedButton.styleFrom( | ||
| primary: Colors.blue, | ||
| onPrimary: Colors.white, | ||
| ), | ||
| child: const Text('Press to ask user to choose a directory'), | ||
| onPressed: () => _getDirectoryPath(context), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /// Widget that displays a text file in a dialog | ||
| class TextDisplay extends StatelessWidget { | ||
| /// Default Constructor | ||
|
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. nit: Here and on a few others (e.g. directoryPath below), the comment is probably unnecessary.
Contributor
Author
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. We have the default analysis settings on, which require docs for anything public. It's easier to just put the not-very-helpful comment than to disable the warning for the line (and I think we should leave it on in general since it's example code). I did a pass over the member variables and tried to give them somewhat more useful comments. |
||
| const TextDisplay(this.directoryPath); | ||
|
|
||
| /// Directory path | ||
| final String directoryPath; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return AlertDialog( | ||
| title: const Text('Selected Directory'), | ||
| content: Scrollbar( | ||
| child: SingleChildScrollView( | ||
| child: Text(directoryPath), | ||
| ), | ||
| ), | ||
| actions: <Widget>[ | ||
| TextButton( | ||
| child: const Text('Close'), | ||
| onPressed: () => Navigator.pop(context), | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
57 changes: 57 additions & 0 deletions
57
packages/file_selector/file_selector_windows/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,57 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
|
|
||
| /// Home Page of the application | ||
| class HomePage extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| final ButtonStyle style = ElevatedButton.styleFrom( | ||
| primary: Colors.blue, | ||
| onPrimary: Colors.white, | ||
| ); | ||
| return Scaffold( | ||
| appBar: AppBar( | ||
| title: const Text('File Selector Demo Home Page'), | ||
| ), | ||
| body: Center( | ||
| child: Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: <Widget>[ | ||
| ElevatedButton( | ||
| style: style, | ||
| child: const Text('Open a text file'), | ||
| onPressed: () => Navigator.pushNamed(context, '/open/text'), | ||
| ), | ||
| const SizedBox(height: 10), | ||
| ElevatedButton( | ||
| style: style, | ||
| child: const Text('Open an image'), | ||
| onPressed: () => Navigator.pushNamed(context, '/open/image'), | ||
| ), | ||
| const SizedBox(height: 10), | ||
| ElevatedButton( | ||
| style: style, | ||
| child: const Text('Open multiple images'), | ||
| onPressed: () => Navigator.pushNamed(context, '/open/images'), | ||
| ), | ||
| const SizedBox(height: 10), | ||
| ElevatedButton( | ||
| style: style, | ||
| child: const Text('Save a file'), | ||
| onPressed: () => Navigator.pushNamed(context, '/save/text'), | ||
| ), | ||
| const SizedBox(height: 10), | ||
| ElevatedButton( | ||
| style: style, | ||
| child: const Text('Open a get directory dialog'), | ||
| onPressed: () => Navigator.pushNamed(context, '/directory'), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
packages/file_selector/file_selector_windows/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,37 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:example/get_directory_page.dart'; | ||
| import 'package:example/home_page.dart'; | ||
| import 'package:example/open_image_page.dart'; | ||
| import 'package:example/open_multiple_images_page.dart'; | ||
| import 'package:example/open_text_page.dart'; | ||
| import 'package:example/save_text_page.dart'; | ||
| import 'package:flutter/material.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: <String, WidgetBuilder>{ | ||
| '/open/image': (BuildContext context) => OpenImagePage(), | ||
| '/open/images': (BuildContext context) => OpenMultipleImagesPage(), | ||
| '/open/text': (BuildContext context) => OpenTextPage(), | ||
| '/save/text': (BuildContext context) => SaveTextPage(), | ||
| '/directory': (BuildContext context) => GetDirectoryPage(), | ||
| }, | ||
| ); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.