-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[cross_file] Updates cross_file to a package separated federated plugin #11010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
dd280a2
0373d5e
38eb1d9
51a74e2
97f60a6
bfb9e0a
ae1aaf3
aac47fe
e419342
295ea46
39d4bbc
fa7f420
b88d137
e57c8bb
cf7239e
4201466
16c61f7
4ae04b7
da418ab
55c6078
410451f
d4bb9c8
224ac8c
f91cc32
3420f3d
e825b1a
5a773b1
abb58f2
1fe476d
3179eae
d447ee9
81597b3
60edb0d
4ebe1ef
a211972
63d018a
d226f93
4a8e246
1aa3ec6
92cc9b3
a0aeddb
1e47058
e571580
644279b
94c3858
4841e6b
1aee6e3
bbbc10f
9029901
303c0c5
7e48889
b1f38e8
c1ddce9
d974867
88c1c8f
712ae02
f7a242e
55aa297
aac1e0a
4610e83
9be385c
1402e67
551f04b
e013d14
c935c98
54177e3
d2b4422
87d2fe4
3b52614
7df932b
7f90065
569cf17
d9095fb
831561b
74d5d04
4352bc6
9bf79ca
27fcc87
6a2c35e
2d501a2
7f40e97
30b062a
e2d0f15
7b34f3d
52fbbaa
4c15493
3075896
4b0b3e4
6b721eb
789ef71
1b24e78
1d1e949
b623ad4
f420e80
6415ea6
00a9f10
5fc9cd5
79a98cb
fe48304
8a5d3cc
a234ecd
9765b61
54d0668
b276f77
9eeb9ed
ac3dcf0
ae1f8e0
409a17d
bae2e4d
6ec9c3f
15f311e
b4799e8
a04ebd4
920bb31
11efbdc
f19b74e
f01d4bd
9ca64a7
bd73776
b70935c
a0c2fd4
c37af83
e4d1d26
28b1679
d845bcb
a6f8336
c58f31b
7ecfd3a
574eb1a
a0169fb
340c462
a1a621c
7c2ad19
b3ebbf5
bb8b149
48bd7e0
ef0b7fc
4104693
b4a47f4
58678a4
784192d
8ac420c
170f6b0
7fee973
7390bfc
3cf62e9
08707df
3f2f880
f9ba45a
761fba6
4a49a21
30210f1
0115b47
a388a69
a6af73c
c93bb93
8fecd6a
15707ad
531dc5c
194a323
1a54c91
5033f3f
fb21706
ff2d369
a3994c1
939a1c0
c62eb16
bc28494
ef08bac
4c34286
afe1231
df66b02
c1c066f
3d9f91e
a408ce9
71f72fe
77a0132
01e5d97
4f9feb1
32c511a
dbee630
9eae34c
04621c3
eab82fc
d43a862
dfe9ecc
77c9cf8
abb39e2
183844d
38b2753
b36b01a
d088cae
f9edbcd
eaed7c4
dfb7ee5
ba16dfc
83ae934
148953a
c4e8634
4a65aa9
e6c3e59
f313769
99016fe
eaede7b
2ebe107
c22d4bc
4492f9c
c1fddbb
dc66e88
10cdaa6
7544671
b38c571
431cf87
eb28858
6ac49c5
2c0293d
712bcf3
b72833a
f99d7ed
b57339c
f52b220
ae5434c
42e67e6
55eeb13
89e5428
8e76180
4dd921b
b63030a
6613d68
6a68362
aa6e666
5c26447
6c5f597
eba22d5
77a6224
43b9fb0
0f3283c
49ae634
a2d34bd
a7de454
8517b1b
44e0676
356487a
1b2f361
50cffbe
ace90a2
a0a4c85
44d1df6
d37cb36
1627c9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| ## NEXT | ||
| ## 0.4.0 | ||
|
|
||
| * Updates `cross_file` to a package-separated federated plugin. | ||
|
Collaborator
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. This will also need to cover the breaking API changes. |
||
| * Updates minimum supported SDK version to Flutter 3.38/Dart 3.10. | ||
|
|
||
| ## 0.3.5+2 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # cross_file | ||
|
|
||
| An abstraction to allow working with files across multiple platforms. | ||
|
|
||
| <?code-excerpt path-base="example/lib"?> | ||
|
|
||
| [](https://pub.dartlang.org/packages/cross_file) | ||
|
|
||
| A Flutter plugin that manages files and interactions with file dialogs. | ||
|
|
||
| | | Android | iOS | Linux | macOS | Web | Windows | | ||
| |-------------|---------|---------|-------|--------|-----|-------------| | ||
| | **Support** | SDK 24+ | iOS 13+ | Any | 10.15+ | Any | Windows 10+ | | ||
|
|
||
| ## Usage | ||
|
|
||
| Import `package:cross_file/cross_file.dart`, instantiate a `XFile` | ||
|
Collaborator
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. I've been scrubbing "import" instructions out of READMEs since it's basic to all packages, and covered on pub.dev already. |
||
| using a path or byte array and use its methods and properties to | ||
| access the file and its metadata. | ||
|
|
||
| Example: | ||
|
|
||
| <?code-excerpt "readme_excerpts.dart (Instantiate)"?> | ||
| ```dart | ||
| final file = XFile.fromUri(Uri.file('assets/hello.txt')); | ||
|
|
||
| debugPrint('File information:'); | ||
| debugPrint('- URI: ${file.uri}'); | ||
| debugPrint('- Name: ${await file.name()}'); | ||
|
|
||
| if (await file.exists()) { | ||
| final String fileContent = await file.readAsString(); | ||
| debugPrint('Content of the file: $fileContent'); | ||
| } | ||
| ``` | ||
|
|
||
| You will find links to the API docs on the [pub page](https://pub.dev/packages/cross_file). | ||
|
Collaborator
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: You can find |
||
|
|
||
| ### Implementation-Specific Features | ||
|
|
||
| Classes in this package contain an underlying platform implementation that provides features that | ||
| are specific to an implementation. | ||
|
|
||
| To access implementation-specific features, start by adding the platform implementation packages to | ||
| your app or package: | ||
|
|
||
| * **dart:io** [cross_file_io](https://pub.dev/packages/cross_file_io/install) | ||
| * **Android Scoped Storage**: [cross_file_android](https://pub.dev/packages/cross_file_android/install) | ||
| * **iOS/macOS App Sandbox**: [cross_file_darwin](https://pub.dev/packages/cross_file_darwin/install) | ||
| * **Web**: [cross_file_web](https://pub.dev/packages/cross_file_web/install) | ||
|
|
||
| Next, add the imports of the implementation packages to your app or package: | ||
|
|
||
| <?code-excerpt "readme_excerpts.dart (platform_imports)"?> | ||
| ```dart | ||
| // Import for Darwin App Sandbox features. | ||
| import 'package:cross_file_darwin/cross_file_darwin.dart'; | ||
| // Import for Web features. | ||
| import 'package:cross_file_web/cross_file_web.dart'; | ||
| ``` | ||
|
|
||
| Now, additional features can be accessed through the platform implementations. Classes | ||
| [XFile], [XDirectory], [ScopedStorageXFile], and [ScopedStorageXDirectory] pass their | ||
| functionality to a class provided by the current platform. Below are a couple of ways to access | ||
| additional functionality provided by the platform and is followed by an example. | ||
|
|
||
| 1. Pass a creation params class provided by a platform implementation to a `fromCreationParams` | ||
| constructor (e.g. `XFile.fromCreationParams`, `XDirectory.fromCreationParams`, etc.). | ||
| 2. Call methods on an implementation of a class by using `getExtension`/`maybeGetExtension` methods (e.g. | ||
| `XFile.getExtension`, `XDirectory.maybeGetExtension`, etc.). | ||
|
|
||
| Below is an example of using additional iOS/macOS and Web features for a `XFile`. | ||
|
|
||
| <?code-excerpt "readme_excerpts.dart (platform_features)"?> | ||
| ```dart | ||
| late final XFile file; | ||
|
|
||
| if (CrossFileWeb.isCurrentImplementation()) { | ||
| final params = WebScopedStorageXFileCreationParams.fromObjectUrl( | ||
| objectUrl: 'blob:https://some/url:for/file', | ||
| ); | ||
| file = XFile.fromCreationParams(params); | ||
| } else if (CrossFileDarwin.isCurrentImplementation()) { | ||
| file = ScopedStorageXFile.fromUri(Uri.file('/my/file.txt')); | ||
| } else { | ||
| file = XFile.fromUri(Uri.file('/my/file.txt')); | ||
| } | ||
|
|
||
| await file | ||
| .maybeGetExtension<SecurityScopedDarwinScopedStorageXFileExtension>() | ||
| ?.startAccessingSecurityScopedResource(); | ||
|
|
||
| debugPrint(await file.readAsString()); | ||
|
|
||
| await file | ||
| .maybeGetExtension<SecurityScopedDarwinScopedStorageXFileExtension>() | ||
| ?.stopAccessingSecurityScopedResource(); | ||
| ``` | ||
|
|
||
| See https://pub.dev/documentation/cross_file_darwin/latest/cross_file_darwin/cross_file_darwin-library.html | ||
| for more details on iOS/macOS App Sandbox features. | ||
|
|
||
| See https://pub.dev/documentation/cross_file_android/latest/cross_file_android/cross_file_android-library.html | ||
| for more details on Android Scoped Storage features. | ||
|
|
||
| See https://pub.dev/documentation/cross_file_io/latest/cross_file_io/cross_file_io-library.html | ||
| for more details on `dart:io` features. | ||
|
|
||
| See https://pub.dev/documentation/cross_file_web/latest/cross_file_web/cross_file_web-library.html | ||
| for more details on Web features. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # cross_file_example | ||
|
|
||
| Demonstrates how to use the cross_file plugin. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| plugins { | ||
| id("com.android.application") | ||
| id("kotlin-android") | ||
| id("dev.flutter.flutter-gradle-plugin") | ||
| } | ||
|
|
||
| android { | ||
| namespace = "dev.flutter.packages.cross_file_example" | ||
| compileSdk = flutter.compileSdkVersion | ||
| ndkVersion = flutter.ndkVersion | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility = JavaVersion.VERSION_17 | ||
| targetCompatibility = JavaVersion.VERSION_17 | ||
| } | ||
|
|
||
| kotlinOptions { | ||
| jvmTarget = JavaVersion.VERSION_17.toString() | ||
| } | ||
|
|
||
| defaultConfig { | ||
| applicationId = "dev.flutter.packages.cross_file_example" | ||
| minSdk = flutter.minSdkVersion | ||
| targetSdk = flutter.targetSdkVersion | ||
| versionCode = flutter.versionCode | ||
| versionName = flutter.versionName | ||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| signingConfig = signingConfigs.getByName("debug") | ||
| } | ||
| } | ||
| lint { | ||
| disable.add("InvalidPackage") | ||
| } | ||
| } | ||
|
|
||
| flutter { | ||
| source = "../.." | ||
| } | ||
|
|
||
| dependencies { | ||
| testImplementation("junit:junit:4.13.2") | ||
| androidTestImplementation("androidx.test:runner:1.2.0") | ||
| androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0") | ||
| api("androidx.test:core:1.4.0") | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package dev.flutter.packages.cross_file_example | ||
|
|
||
| import androidx.test.rule.ActivityTestRule | ||
| import dev.flutter.plugins.integration_test.FlutterTestRunner | ||
| import io.flutter.plugins.DartIntegrationTest | ||
| import org.junit.Rule | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @DartIntegrationTest | ||
| @RunWith(FlutterTestRunner::class) | ||
| class MainActivityTest { | ||
| @JvmField @Rule var rule = ActivityTestRule(MainActivity::class.java) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <!-- The INTERNET permission is required for development. Specifically, | ||
| the Flutter tool needs it to communicate with the running application | ||
| to allow setting breakpoints, to provide hot reload, etc. | ||
| --> | ||
| <uses-permission android:name="android.permission.INTERNET"/> | ||
| <application android:usesCleartextTraffic="true"> | ||
| <activity | ||
| android:name="dev.flutter.packages.cross_file_example.DriverExtensionActivity" | ||
| android:launchMode="singleTop" | ||
| android:theme="@style/LaunchTheme" | ||
| android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
| android:hardwareAccelerated="true" | ||
| android:windowSoftInputMode="adjustResize"> | ||
| <meta-data | ||
| android:name="io.flutter.Entrypoint" | ||
| android:value="integrationTestMain" /> | ||
| </activity> | ||
| </application> | ||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <application | ||
| android:label="cross_file_example" | ||
| android:name="${applicationName}" | ||
| android:icon="@mipmap/ic_launcher"> | ||
| <activity | ||
| android:name=".MainActivity" | ||
| android:exported="true" | ||
| android:launchMode="singleTop" | ||
| android:taskAffinity="" | ||
| android:theme="@style/LaunchTheme" | ||
| android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
| android:hardwareAccelerated="true" | ||
| android:windowSoftInputMode="adjustResize"> | ||
| <!-- Specifies an Android theme to apply to this Activity as soon as | ||
| the Android process has started. This theme is visible to the user | ||
| while the Flutter UI initializes. After that, this theme continues | ||
| to determine the Window background behind the Flutter UI. --> | ||
| <meta-data | ||
| android:name="io.flutter.embedding.android.NormalTheme" | ||
| android:resource="@style/NormalTheme" | ||
| /> | ||
| <intent-filter> | ||
| <action android:name="android.intent.action.MAIN"/> | ||
| <category android:name="android.intent.category.LAUNCHER"/> | ||
| </intent-filter> | ||
| </activity> | ||
| <!-- Don't delete the meta-data below. | ||
| This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> | ||
| <meta-data | ||
| android:name="flutterEmbedding" | ||
| android:value="2" /> | ||
| </application> | ||
| <!-- Required to query activities that can process text, see: | ||
| https://developer.android.com/training/package-visibility and | ||
| https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT. | ||
|
|
||
| In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. --> | ||
| <queries> | ||
| <intent> | ||
| <action android:name="android.intent.action.PROCESS_TEXT"/> | ||
| <data android:mimeType="text/plain"/> | ||
| </intent> | ||
| </queries> | ||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package dev.flutter.packages.cross_file_example | ||
|
|
||
| import io.flutter.embedding.android.FlutterActivity | ||
|
|
||
| /** Test Activity that sets the name of the Dart method entrypoint in the manifest. */ | ||
| class DriverExtensionActivity : FlutterActivity() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package dev.flutter.packages.cross_file_example | ||
|
|
||
| import io.flutter.embedding.android.FlutterActivity | ||
|
|
||
| class MainActivity : FlutterActivity() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| package io.flutter.plugins | ||
|
|
||
| /* | ||
| * Annotation to aid repository tooling in determining if a test is | ||
| * a native java unit test or a java class with a dart integration. | ||
| * | ||
| * See: https://github.com/flutter/flutter/blob/master/docs/ecosystem/testing/Plugin-Tests.md#enabling-android-ui-tests | ||
| * for more information. | ||
| */ | ||
| @Retention(AnnotationRetention.RUNTIME) | ||
| @Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS) | ||
| annotation class DartIntegrationTest |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- Modify this file to customize your launch splash screen --> | ||
| <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <item android:drawable="?android:colorBackground" /> | ||
|
|
||
| <!-- You can insert your own image assets here --> | ||
| <!-- <item> | ||
| <bitmap | ||
| android:gravity="center" | ||
| android:src="@mipmap/launch_image" /> | ||
| </item> --> | ||
| </layer-list> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be down in the section starting at line 85.