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
[path_provider] Add Windows support #2818
Merged
stuartmorgan-g
merged 40 commits into
flutter:master
from
timsneath:path_provider_windows
Sep 18, 2020
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
7e018b9
Initial Windows repo
712c043
Implementation for getTemporaryPath() and getDownloadsPath()
55429f6
Tidy up Windows plugin implementation
52d5b0d
Add folder documentation comments.
aea6a4c
Add Windows runner
f20a00e
Fix doc comment nit
1be04d7
Set pubspec version
306868e
Add manual registration of Windows plug-in
cd0ea88
Fix bug in pubspec
0eba356
Tweaks
06bd98f
Remove windows folder
383ef8f
Add missing copyright comment
ad0c2b9
More minor copyright tweaks
f264046
Add warning
03a126e
Bump changelog
5057d47
Wrap pointer allocation in try/free
9da128b
Merge remote-tracking branch 'upstream/master' into path_provider_win…
37eba73
path endsWith
a3a2d41
Trim back comment on TEMP environment variable
6048f43
Switch to the improved manual Dart registration used in shared_prefer…
stuartmorgan-g 30ef537
Fix endorsement
stuartmorgan-g ca07f04
Version bump for endorsement
stuartmorgan-g 41c704e
Use newer format license
stuartmorgan-g d017a20
Update README for path_provider_windows to have correct path_provider…
stuartmorgan-g 22afc78
Dependency fixes in example
stuartmorgan-g bd11efc
Comment cleanup, remove getLibraryPath, make applitionSupportPath con…
stuartmorgan-g 3cd2f98
Improve unit test coverage; skip on non-Windows
stuartmorgan-g 3d49b16
Make example self-contained
stuartmorgan-g 845074f
Ensure that temp directory exists before returning it
stuartmorgan-g a3c2bf2
Dart format
stuartmorgan-g 676fd02
Use actual executable name
stuartmorgan-g cd2f366
Use 0.0.2, since there were code changes
stuartmorgan-g 7d46f63
Use VERSIONINFO to figure out the appdata subdir
stuartmorgan-g 80a0b6a
Use TestOn
stuartmorgan-g 3a3fdb7
Cap directory component length
stuartmorgan-g 954a8df
Revert "Use TestOn"
stuartmorgan-g be299b9
Update the test added after the revert change
stuartmorgan-g e826b17
Use a named constant for the language code
stuartmorgan-g 370f3ce
Make the name more accurate
stuartmorgan-g fe6d472
Fix long path handling
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
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
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,3 @@ | ||
.packages | ||
.flutter-plugins | ||
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,11 @@ | ||
## 0.0.2 | ||
|
||
* README update for endorsement. | ||
* Changed getApplicationSupportPath location. | ||
* Removed getLibraryPath. | ||
|
||
## 0.0.1+2 | ||
stuartmorgan-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* The initial implementation of path_provider for Windows | ||
* Implements getTemporaryPath, getApplicationSupportPath, getLibraryPath, | ||
getApplicationDocumentsPath and getDownloadsPath. |
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 2017 The Chromium 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,31 @@ | ||
# path_provider_windows | ||
|
||
The Windows implementation of [`path_provider`][1]. | ||
|
||
**Please set your constraint 10000 to `path_provider_windows: '>=0.0.y+x <2.0.0'`** | ||
|
||
## Backward compatible 1.0.0 version is coming | ||
|
||
The plugin has reached a stable API, we guarantee that version `1.0.0` will be backward compatible with `0.0.y+z`. | ||
Please use `path_provider_windows: '>=0.0.y+x <2.0.0'` as your dependency constraint to allow a smoother ecosystem migration. | ||
For more details see: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 | ||
|
||
## Usage | ||
|
||
### Import the package | ||
|
||
This package has been endorsed, meaning that you only need to add `path_provider` | ||
as a dependency in your `pubspec.yaml`. It will be automatically included in your app | ||
when you depend on `package:path_provider`. | ||
|
||
This is what the above means to your `pubspec.yaml`: | ||
|
||
```yaml | ||
... | ||
dependencies: | ||
... | ||
path_provider: ^1.6.15 | ||
... | ||
``` | ||
|
||
[1]:../ |
44 changes: 44 additions & 0 deletions
44
packages/path_provider/path_provider_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,44 @@ | ||
# 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 | ||
|
||
# Exceptions to above rules. | ||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages |
10 changes: 10 additions & 0 deletions
10
packages/path_provider/path_provider_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: f2320c3b7a42bc27e7f038212eed1b01f4269641 | ||
channel: master | ||
|
||
project_type: app |
8 changes: 8 additions & 0 deletions
8
packages/path_provider/path_provider_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,8 @@ | ||
# path_provider_windows_example | ||
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. do we need a separate sample for Windows? won't the normal path_provider sample do? 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. There's an open question in the longer term about how to best structure the tests and examples for federated plugins. The plugin repo tooling expects them though, and it does have value in the general case:
So long term, TBD, short term, this is the standard practice we've been following. |
||
|
||
Demonstrates how to use the path_provider_windows plugin. | ||
|
||
## Getting Started | ||
|
||
For help getting started with Flutter, view our online | ||
[documentation](http://flutter.io/). |
93 changes: 93 additions & 0 deletions
93
packages/path_provider/path_provider_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,93 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// ignore_for_file: public_member_api_docs | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:path_provider_windows/path_provider_windows.dart'; | ||
|
||
void main() async { | ||
runApp(MyApp()); | ||
} | ||
|
||
/// Sample app | ||
class MyApp extends StatefulWidget { | ||
@override | ||
_MyAppState createState() => _MyAppState(); | ||
} | ||
|
||
class _MyAppState extends State<MyApp> { | ||
String _tempDirectory = 'Unknown'; | ||
String _downloadsDirectory = 'Unknown'; | ||
String _appSupportDirectory = 'Unknown'; | ||
String _documentsDirectory = 'Unknown'; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
initDirectories(); | ||
} | ||
|
||
// Platform messages are asynchronous, so we initialize in an async method. | ||
Future<void> initDirectories() async { | ||
String tempDirectory; | ||
String downloadsDirectory; | ||
String appSupportDirectory; | ||
String documentsDirectory; | ||
final PathProviderWindows provider = PathProviderWindows(); | ||
|
||
try { | ||
tempDirectory = await provider.getTemporaryPath(); | ||
} catch (exception) { | ||
tempDirectory = 'Failed to get temp directory: $exception'; | ||
} | ||
try { | ||
downloadsDirectory = await provider.getDownloadsPath(); | ||
} catch (exception) { | ||
downloadsDirectory = 'Failed to get downloads directory: $exception'; | ||
} | ||
|
||
try { | ||
documentsDirectory = await provider.getApplicationDocumentsPath(); | ||
} catch (exception) { | ||
documentsDirectory = 'Failed to get documents directory: $exception'; | ||
} | ||
|
||
try { | ||
appSupportDirectory = await provider.getApplicationSupportPath(); | ||
} catch (exception) { | ||
appSupportDirectory = 'Failed to get app support directory: $exception'; | ||
} | ||
|
||
setState(() { | ||
_tempDirectory = tempDirectory; | ||
_downloadsDirectory = downloadsDirectory; | ||
_appSupportDirectory = appSupportDirectory; | ||
_documentsDirectory = documentsDirectory; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Path Provider example app'), | ||
), | ||
body: Center( | ||
child: Column( | ||
children: [ | ||
Text('Temp Directory: $_tempDirectory\n'), | ||
Text('Documents Directory: $_documentsDirectory\n'), | ||
Text('Downloads Directory: $_downloadsDirectory\n'), | ||
Text('Application Support Directory: $_appSupportDirectory\n'), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/path_provider/path_provider_windows/example/pubspec.yaml
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 ch
4E34
aracters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: path_provider_example | ||
description: Demonstrates how to use the path_provider plugin. | ||
|
||
dependencies: | ||
flutter: | ||
sdk: flutter | ||
path_provider_windows: any | ||
|
||
dependency_overrides: | ||
path_provider_windows: | ||
stuartmorgan-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
path: ../ | ||
|
||
dev_dependencies: | ||
e2e: ^0.2.1 | ||
flutter_driver: | ||
sdk: flutter | ||
test: any | ||
pedantic: ^1.8.0 | ||
|
||
flutter: | ||
uses-material-design: true |
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.