8000 [file_selector] Import Linux implementation from FDE (#6292) · flutter/plugins@31ffdb5 · GitHub
[go: up one dir, main page]

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

Commit 31ffdb5

Browse files
[file_selector] Import Linux implementation from FDE (#6292)
1 parent 3f287af commit 31ffdb5

40 files changed

+2207
-30
lines changed

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ task:
212212
- flutter config --enable-linux-desktop
213213
- ./script/tool_runner.sh build-examples --linux
214214
native_test_script:
215-
- ./script/tool_runner.sh native-test --linux --no-integration
215+
- xvfb-run ./script/tool_runner.sh native-test --linux --no-integration
216216
drive_script:
217-
- xvfb-run ./script/tool_runner.sh drive-examples --linux
217+
- xvfb-run ./script/tool_runner.sh drive-examples --linux --exclude=script/configs/exclude_integration_linux.yaml
218218

219219
# Heavy-workload Linux tasks.
220220
# These use machines with more CPUs and memory, so will reduce parallelization
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.dart_tool
2+
.packages
3+
.flutter-plugins
4+
.flutter-plugins-dependencies
5+
pubspec.lock
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the Flutter project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## 0.9.0
2+
3+
* Moves source to flutter/plugins.
4+
5+
## 0.0.3
6+
7+
* Adds Dart implementation for in-package method channel.
8+
9+
## 0.0.2+1
10+
11+
* Updates README
12+
13+
## 0.0.2
14+
15+
* Updates SDK constraint to signal compatibility with null safety.
16+
17+
## 0.0.1
18+
19+
* Initial Linux implementation of `file_selector`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2013 The Flutter Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# file\_selector\_linux
2+
3+
The Linux implementation of [`file_selector`][1].
4+
5+
## Usage
6+
7+
This package is [endorsed][2], which means you can simply use `file_selector`
8+
normally. This package will be automatically included in your app when you do.
9+
10+
[1]: https://pub.dev/packages/file_selector
11+
[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
**/ios/Flutter/.last_build_id
26+
.dart_tool/
27+
.flutter-plugins
28+
.flutter-plugins-dependencies
29+
.packages
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Web related
35+
lib/generated_plugin_registrant.dart
36+
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
42+
43+
# Currently only web supported
44+
android/
45+
ios/
46+
47+
# Exceptions to above rules.
48+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 7736f3bc90270dcb0480db2ccffbf1d13c28db85
8+
channel: dev
9+
10+
project_type: app
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# `file_selector_linux` example
2+
3+
Demonstrates Linux implementation of the
4+
[`file_selector` plugin](https://pub.dev/packages/file_selector).
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
6+
import 'package:flutter/material.dart';
7+
8+
/// Screen that allows the user to select a directory using `getDirectoryPath`,
9+
/// then displays the selected directory in a dialog.
10+
class GetDirectoryPage extends StatelessWidget {
11+
/// Default Constructor
12+
const GetDirectoryPage({Key? key}) : super(key: key);
13+
14+
Future<void> _getDirectoryPath(BuildContext context) async {
15+
const String confirmButtonText = 'Choose';
16+
final String? directoryPath =
17+
await FileSelectorPlatform.instance.getDirectoryPath(
18+
confirmButtonText: confirmButtonText,
19+
);
20+
if (directoryPath == null) {
21+
// Operation was canceled by the user.
22+
return;
23+
}
24+
await showDialog<void>(
25+
context: context,
26+
builder: (BuildContext context) => TextDisplay(directoryPath),
27+
);
28+
}
29+
30+
@override
31+
Widget build(BuildContext context) {
32+
return Scaffold(
33+
appBar: AppBar(
34+
title: const Text('Open a text file'),
35+
),
36+
body: Center(
37+
child: Column(
38+
mainAxisAlignment: MainAxisAlignment.center,
39+
children: <Widget>[
40+
ElevatedButton(
41+
style: ElevatedButton.styleFrom(
42+
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
43+
// ignore: deprecated_member_use
44+
primary: Colors.blue,
45+
// ignore: deprecated_member_use
46+
onPrimary: Colors.white,
47+
),
48+
child: const Text('Press to ask user to choose a directory'),
49+
onPressed: () => _getDirectoryPath(context),
50+
),
51+
],
52+
),
53+
),
54+
);
55+
}
56+
}
57+
58+
/// Widget that displays a text file in a dialog.
59+
class TextDisplay extends StatelessWidget {
60+
/// Creates a `TextDisplay`.
61+
const TextDisplay(this.directoryPath, {Key? key}) : super(key: key);
62+
63+
/// The path selected in the dialog.
64+
final String directoryPath;
65+
66+
@override
67+
Widget build(BuildContext context) {
68+
return AlertDialog(
69+
title: const Text('Selected Directory'),
70+
content: Scrollbar(
71+
child: SingleChildScrollView(
72+
child: Text(directoryPath),
73+
),
74+
),
75+
actions: <Widget>[
76+
TextButton(
77+
child: const Text('Close'),
78+
onPressed: () => Navigator.pop(context),
79+
),
80+
],
81+
);
82+
}
83+
}

0 commit comments

Comments
 (0)
0