Skip to content

Commit

Permalink
prepare v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TesteurManiak committed Jun 7, 2022
1 parent 560ada7 commit a5565e2
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 5 deletions.
6 changes: 6 additions & 0 deletions flutter_file_saver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
## 0.4.0

* Added support for MacOS with [flutter_file_manager_macos](https://pub.dev/packages/flutter_file_manager_macos)
* Added method `writeFileAsBytes`

## 0.3.0

* Added support for iOS with [flutter_file_manager_ios](https://pub.dev/packages/flutter_file_manager_ios)
* Added `example/` project

## 0.2.1

Expand Down
10 changes: 9 additions & 1 deletion flutter_file_saver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ Add the following permissions to your `macos/Runner/DebugProfile.entitlements`:
```xml
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
```
```

## TODO

* Use method channel on Android to save the file in the download folder
* Support for Windows & Linux
* Support custom paths
* Improve documentation
* Add tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import FlutterMacOS
import Foundation

import flutter_file_manager_macos
import path_provider_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterFileManagerMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterFileManagerMacosPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}
28 changes: 28 additions & 0 deletions flutter_file_saver/example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PODS:
- flutter_file_manager_macos (0.0.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- path_provider_macos (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- flutter_file_manager_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_file_manager_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)

EXTERNAL SOURCES:
flutter_file_manager_macos:
:path: Flutter/ephemeral/.symlinks/plugins/flutter_file_manager_macos/macos
FlutterMacOS:
:path: Flutter/ephemeral
path_provider_macos:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos

SPEC CHECKSUMS:
flutter_file_manager_macos: 11df72b919a6e010c8e03ec6adf7439f0319032b
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

COCOAPODS: 1.11.2
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
C30290E9683E0AE83ADB01B4 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003A577A0A66433D9B99917 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -54,7 +55,7 @@
/* Begin PBXFileReference section */
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; };
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
Expand All @@ -66,15 +67,20 @@
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
6003A577A0A66433D9B99917 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
76A0AE3916AC8BB9A2B05BB3 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
A00170F312B9AB27CE323E4F /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
E3039A299C23ED30881E6DB8 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
33CC10EA2044A3C60003C045 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C30290E9683E0AE83ADB01B4 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -99,6 +105,7 @@
33CEB47122A05771004F2AC0 /* Flutter */,
33CC10EE2044A3C60003C045 /* Products */,
D73912EC22F37F3D000D13A0 /* Frameworks */,
63A583D0ED0C4723AC54A200 /* Pods */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -145,9 +152,21 @@
path = Runner;
sourceTree = "<group>";
};
63A583D0ED0C4723AC54A200 /* Pods */ = {
isa = PBXGroup;
children = (
E3039A299C23ED30881E6DB8 /* Pods-Runner.debug.xcconfig */,
76A0AE3916AC8BB9A2B05BB3 /* Pods-Runner.release.xcconfig */,
A00170F312B9AB27CE323E4F /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
D73912EC22F37F3D000D13A0 /* Frameworks */ = {
isa = PBXGroup;
children = (
6003A577A0A66433D9B99917 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand All @@ -159,11 +178,13 @@
isa = PBXNativeTarget;
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
2854492694F176803209C04F /* [CP] Check Pods Manifest.lock */,
33CC10E92044A3C60003C045 /* Sources */,
33CC10EA2044A3C60003C045 /* Frameworks */,
33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */,
3CC4C8E08F5BD4F47F1E9DE0 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -233,6 +254,28 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2854492694F176803209C04F /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -270,6 +313,23 @@
shellPath = /bin/sh;
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
};
3CC4C8E08F5BD4F47F1E9DE0 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion flutter_file_saver/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter_file_manager_macos:
dependency: transitive
description:
name: flutter_file_manager_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter_file_manager_platform_interface:
dependency: transitive
description:
Expand All @@ -110,7 +117,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.3.0"
version: "0.4.0"
flutter_lints:
dependency: "direct dev"
description:
Expand Down
42 changes: 41 additions & 1 deletion flutter_file_saver/lib/flutter_file_saver.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'dart:io' as io;
import 'dart:typed_data';

import 'package:flutter/foundation.dart';
import 'package:flutter_file_manager_android/flutter_file_manager_android.dart';
import 'package:flutter_file_manager_ios/flutter_file_manager_ios.dart';
import 'package:flutter_file_manager_macos/flutter_file_manager_macos.dart';
import 'package:flutter_file_manager_platform_interface/flutter_file_manager_platform_interface.dart';

class FlutterFileSaver {
Expand All @@ -25,20 +27,58 @@ class FlutterFileSaver {
FileManagerPlatform.instance = FlutterFileManagerAndroid();
} else if (io.Platform.isIOS) {
FileManagerPlatform.instance = FlutterFileManagerIos();
} else if (io.Platform.isMacOS) {
FileManagerPlatform.instance = FlutterFileManagerMacos();
}
}
_manualRegistrationNeeded = false;
}
return FileManagerPlatform.instance;
}

/// Write [data] inside [fileName] and return the path to the file.
/// Write [data] inside [fileName] and return the path to the file. The
/// parameter is only used on web.
///
/// {@template flutterFileSaver.web.mimeType}
/// ### Web only
///
/// The parameter [type] is only used to define the encoding type of the
/// created file.
/// If it is `null`, type will be infered from the [fileName] (e.g:
/// `test.json` will infer the [MimeType.json]).
/// {@endtemplate}
///
/// {@template flutterFileSaver.macos.openFinder}
/// ### MacOS only
///
/// This method will also open the finder pointing to the folder
/// containing the file.
/// {@endtemplate}
Future<String> writeFileAsString({
required String fileName,
required String data,
MimeType? type,
}) =>
_platform.writeFileAsString(
fileName: fileName,
data: data,
type: type,
);

/// Write [bytes] inside [fileName] and return the path to the file. The
/// parameter is only used on web.
///
/// {@macro flutterFileSaver.web.mimeType}
///
/// {@macro flutterFileSaver.macos.openFinder}
Future<String> writeFileAsBytes({
required String fileName,
required Uint8List bytes,
MimeType? type,
}) =>
_platform.writeFile(
fileName: fileName,
bytes: bytes,
type: type,
);
}
5 changes: 4 additions & 1 deletion flutter_file_saver/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_file_saver
description: Interface to provide a way to save files on the device in Flutter.
version: 0.3.0
version: 0.4.0
homepage: https://github.com/TesteurManiak/flutter_file_saver
repository: https://github.com/TesteurManiak/flutter_file_saver/tree/main/flutter_file_saver

Expand All @@ -13,6 +13,7 @@ dependencies:
sdk: flutter
flutter_file_manager_android: ^1.0.1
flutter_file_manager_ios: ^1.0.0
flutter_file_manager_macos: ^1.0.0
flutter_file_manager_platform_interface: ^1.0.2
flutter_file_manager_web: ^1.0.2

Expand All @@ -30,3 +31,5 @@ flutter:
default_package: flutter_file_manager_ios
web:
default_package: flutter_file_manager_web
macos:
default_package: flutter_file_manager_macos

0 comments on commit a5565e2

Please sign in to comment.