forked from flutter/plugins
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[path_provider] Add Windows support (flutter#2818)
Implements path_provider for Windows, adding path_provider_windows and endorsing it in path_provider.
- Loading branch information
1 parent
7319017
commit aba492d
Showing
20 changed files
with
946 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 | ||
|
||
* The initial implementation of path_provider for Windows | ||
* Implements getTemporaryPath, getApplicationSupportPath, getLibraryPath, | ||
getApplicationDocumentsPath and getDownloadsPath. |
This file contains 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 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 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 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 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 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 | ||
|
||
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 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 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,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: | ||
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.