Browse Source

[path_provider] Implement path_provider plugin. OMP#OS-16308

merge-requests/11/merge
Vitaliy Zarubin 2 years ago
parent
commit
2e6576d67e
  1. 31
      packages/path_provider/path_provider_aurora/.gitignore
  2. 41
      packages/path_provider/path_provider_aurora/README.md
  3. 4
      packages/path_provider/path_provider_aurora/analysis_options.yaml
  4. BIN
      packages/path_provider/path_provider_aurora/data/preview.png
  5. 47
      packages/path_provider/path_provider_aurora/example/.gitignore
  6. 21
      packages/path_provider/path_provider_aurora/example/README.md
  7. 4
      packages/path_provider/path_provider_aurora/example/analysis_options.yaml
  8. 1
      packages/path_provider/path_provider_aurora/example/aurora/.gitignore
  9. 50
      packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt
  10. 12
      packages/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop
  11. BIN
      packages/path_provider/path_provider_aurora/example/aurora/icons/108x108.png
  12. BIN
      packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png
  13. BIN
      packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png
  14. BIN
      packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png
  15. 13
      packages/path_provider/path_provider_aurora/example/aurora/main.cpp
  16. 31
      packages/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_example.spec
  17. 226
      packages/path_provider/path_provider_aurora/example/lib/main.dart
  18. 324
      packages/path_provider/path_provider_aurora/example/pubspec.lock
  19. 26
      packages/path_provider/path_provider_aurora/example/pubspec.yaml
  20. 91
      packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart
  21. 40
      packages/path_provider/path_provider_aurora/pubspec.yaml

31
packages/path_provider/path_provider_aurora/.gitignore vendored

@ -0,0 +1,31 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# 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
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
/.metadata

41
packages/path_provider/path_provider_aurora/README.md

@ -0,0 +1,41 @@
# path_provider_aurora
The Aurora OS implementation of [`path_provider`](https://pub.dev/packages/path_provider).
Documentation for setting permissions can be found [here](https://developer.auroraos.ru/doc/software_development/reference/user_data).
## Usage
This package is not an _endorsed_ implementation of `path_provider`.
Therefore, you have to include `path_provider_aurora` alongside `path_provider` as dependencies in your `pubspec.yaml` file.
**pubspec.yaml**
```yaml
dependencies:
path_provider: ^2.0.14
path_provider_aurora:
path: # path to folder with plugin
```
***.dart**
```dart
import 'package:path_provider/path_provider.dart';
final Directory tempDir = await getTemporaryDirectory();
final Directory appDocumentsDir = await getApplicationDocumentsDirectory();
final Directory? downloadsDir = await getDownloadsDirectory();
```
## Supported APIs
- [x] `getTemporaryDirectory` - Returns a directory location where user-specific non-essential (cached) data should be written
- [ ] `getApplicationSupportDirectory`
- [ ] `getLibraryDirectory`
- [x] `getApplicationDocumentsDirectory` - Returns the directory containing user document files.
- [ ] `getExternalStorageDirectory`
- [ ] `getExternalCacheDirectories`
- [x] `getExternalStorageDirectories` - There is no concept of External in Aurora OS, but this interface allows you to get the pictures/music/movies directory
- [x] `getDownloadsDirectory`- Returns a directory for user's downloaded files.

4
packages/path_provider/path_provider_aurora/analysis_options.yaml

@ -0,0 +1,4 @@
# Copyright (c) 2023. Open Mobile Platform LLC.
# License: Proprietary.
include: package:flutter_lints/flutter.yaml

BIN
packages/path_provider/path_provider_aurora/data/preview.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

47
packages/path_provider/path_provider_aurora/example/.gitignore vendored

@ -0,0 +1,47 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# 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/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
# Aurora generated
/aurora/flutter

21
packages/path_provider/path_provider_aurora/example/README.md

@ -0,0 +1,21 @@
# path_provider_aurora_example
Demonstrates how to use the path_provider_aurora plugin.
## Build
```shell
# Add an alias if it doesn't already exist
alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter
# Get dependencies
flutter-aurora pub get
# Run build
flutter-aurora build aurora --release # [--release|--debug|--profile]
```
You can collect, sign, run an example on the device with a script located in the `script/build_example.sh`
More information in `build_example.sh`.
### Preview example
![preview.png](../data/preview.png)

4
packages/path_provider/path_provider_aurora/example/analysis_options.yaml

@ -0,0 +1,4 @@
# Copyright (c) 2023. Open Mobile Platform LLC.
# License: Proprietary.
include: package:flutter_lints/flutter.yaml

1
packages/path_provider/path_provider_aurora/example/aurora/.gitignore vendored

@ -0,0 +1 @@
flutter/ephemeral

50
packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt

@ -0,0 +1,50 @@
# Copyright (c) 2023. Open Mobile Platform LLC.
# License: Proprietary.
cmake_minimum_required(VERSION 3.10)
project(com.example.path_provider_aurora_example LANGUAGES CXX)
include(GNUInstallDirs)
set(BINARY_NAME ${CMAKE_PROJECT_NAME})
set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_SKIP_RPATH OFF)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib")
find_package(PkgConfig REQUIRED)
pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder)
add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder)
target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR})
include(flutter/generated_plugins.cmake)
set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME})
set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications)
set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor)
add_custom_command(TARGET ${BINARY_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so
${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so)
install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR})
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR})
foreach(ICONS_SIZE 86x86 108x108 128x128 172x172)
install(FILES icons/${ICONS_SIZE}.png
RENAME ${BINARY_NAME}.png
DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/)
endforeach(ICONS_SIZE)

12
packages/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop

@ -0,0 +1,12 @@
[Desktop Entry]
Type=Application
Name=path_provider_aurora_example
Comment=Demonstrates how to use the path_provider_aurora plugin.
Icon=com.example.path_provider_aurora_example
Exec=/usr/bin/com.example.path_provider_aurora_example
X-Nemo-Application-Type=silica-qt5
[X-Application]
Permissions=UserDirs
OrganizationName=com.example
ApplicationName=path_provider_aurora_example

BIN
packages/path_provider/path_provider_aurora/example/aurora/icons/108x108.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

13
packages/path_provider/path_provider_aurora/example/aurora/main.cpp

@ -0,0 +1,13 @@
/*
* Copyright (c) 2023. Open Mobile Platform LLC.
* License: Proprietary.
*/
#include <flutter/application.h>
#include "generated_plugin_registrant.h"
int main(int argc, char *argv[]) {
Application::Initialize(argc, argv);
RegisterPlugins();
Application::Launch();
return 0;
}

31
packages/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_example.spec

@ -0,0 +1,31 @@
%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$
%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$
Name: com.example.path_provider_aurora_example
Summary: Demonstrates how to use the path_provider_aurora plugin.
Version: 0.1.0
Release: 1
License: Proprietary
Source0: %{name}-%{version}.tar.zst
BuildRequires: cmake
BuildRequires: pkgconfig(flutter-embedder)
%description
%{summary}.
%prep
%autosetup
%build
%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type}
%make_build
%install
%make_install
%files
%{_bindir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png

226
packages/path_provider/path_provider_aurora/example/lib/main.dart

@ -0,0 +1,226 @@
/*
* Copyright (c) 2023. Open Mobile Platform LLC.
* License: Proprietary.
*/
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path_provider_aurora/path_provider_aurora.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String? _error;
String? _pathApplicationSupportDirectory;
String? _pathTempDirectory;
String? _pathApplicationDocumentsPath;
String? _pathDownloadsPath;
String? _pathPictures;
String? _pathMusic;
String? _pathMovies;
@override
void initState() {
super.initState();
loadPathDirectory();
}
/// Asynchronous function receiving directory paths
Future<void> loadPathDirectory() async {
try {
// Get directories
Directory? applicationSupportDirectory =
await getApplicationSupportDirectory();
Directory? tempDirectory = await getTemporaryDirectory();
Directory? pathApplicationDocumentsPath =
await getApplicationDocumentsDirectory();
Directory? pathDownloadsPath = await getDownloadsDirectory();
List<Directory>? pathPictures =
await getExternalStorageDirectories(type: StorageDirectory.pictures);
List<Directory>? pathMusic =
await getExternalStorageDirectories(type: StorageDirectory.music);
List<Directory>? pathMovies =
await getExternalStorageDirectories(type: StorageDirectory.movies);
// Update state variable
setState(() {
_pathApplicationSupportDirectory = applicationSupportDirectory.path;
_pathTempDirectory = tempDirectory.path;
_pathApplicationDocumentsPath = pathApplicationDocumentsPath.path;
_pathDownloadsPath = pathDownloadsPath?.path;
_pathPictures = pathPictures?.first.path;
_pathMusic = pathMusic?.first.path;
_pathMovies = pathMovies?.first.path;
});
} on Exception catch (e) {
setState(() {
_error = e.toString();
});
}
}
@override
Widget build(BuildContext context) {
const textStyleWhite = TextStyle(fontSize: 18, color: Colors.white);
const textStyleTitle = TextStyle(fontSize: 20, color: Colors.black);
const textStylePath = TextStyle(fontSize: 18, color: Colors.black54);
const spaceMedium = SizedBox(height: 20);
const spaceSmall = SizedBox(height: 10);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Example path_provider'),
),
body: Stack(
children: [
// Error message
Visibility(
visible: _error != null,
child: Center(
child: Padding(
padding: const EdgeInsets.all(16),
child: Container(
padding: const EdgeInsets.all(20),
decoration: const BoxDecoration(
color: Colors.redAccent,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
child: Text(
_error ?? '',
style: textStyleWhite,
),
),
),
),
),
// List directories path
Visibility(
visible: _error == null,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
child: Center(
child: Column(
children: [
// Info
Container(
padding: const EdgeInsets.all(20),
decoration: const BoxDecoration(
color: Colors.green,
borderRadius:
BorderRadius.all(Radius.circular(10.0)),
),
child: const Text(
'Demo application demonstration implementation of path_provider',
style: textStyleWhite,
textAlign: TextAlign.center,
),
),
const SizedBox(height: 30),
// TempDirectory
const Text(
'ApplicationSupportDirectory',
style: textStyleTitle,
),
spaceSmall,
Text(
_pathApplicationSupportDirectory ?? 'Not found.',
style: textStylePath,
),
spaceMedium,
// TempDirectory
const Text(
'TempDirectory',
style: textStyleTitle,
),
spaceSmall,
Text(
_pathTempDirectory ?? 'Not found.',
style: textStylePath,
),
spaceMedium,
// ApplicationDocumentsPath
const Text(
'ApplicationDocumentsPath',
style: textStyleTitle,
),
spaceSmall,
Text(
_pathApplicationDocumentsPath ?? 'Not found.',
style: textStylePath,
),
spaceMedium,
// DownloadsPath
const Text(
'DownloadsPath',
style: textStyleTitle,
),
spaceSmall,
Text(
_pathDownloadsPath ?? 'Not found.',
style: textStylePath,
),
spaceMedium,
// Pictures
const Text(
'Pictures',
style: textStyleTitle,
),
spaceSmall,
Text(
_pathPictures ?? 'Not found.',
style: textStylePath,
),
spaceMedium,
// Music
const Text(
'Music',
style: textStyleTitle,
),
spaceSmall,
Text(
_pathMusic ?? 'Not found.',
style: textStylePath,
),
spaceMedium,
// Movies
const Text(
'Movies',
style: textStyleTitle,
),
spaceSmall,
Text(
_pathMovies ?? 'Not found.',
style: textStylePath,
),
],
),
),
),
),
),
],
),
),
);
}
}

324
packages/path_provider/path_provider_aurora/example/pubspec.lock

@ -0,0 +1,324 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.4"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.5"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.2"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
package_info_plus:
dependency: transitive
description:
name: package_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
package_info_plus_aurora:
dependency: transitive
description:
path: "packages/package_info_plus/package_info_plus_aurora"
ref: dev
resolved-ref: "47dd76ca473269566811d8c48fbfd22f1d8120f9"
url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git"
source: git
version: "0.0.1"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.15"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.27"
path_provider_aurora:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.0.1"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.3"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.11"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.7"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.12"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.2"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.4"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
xdga_directories:
dependency: transitive
description:
path: "packages/xdga_directories"
ref: dev
resolved-ref: "47dd76ca473269566811d8c48fbfd22f1d8120f9"
url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git"
source: git
version: "0.0.1"
sdks:
dart: ">=2.18.6 <3.0.0"
flutter: ">=3.3.0"

26
packages/path_provider/path_provider_aurora/example/pubspec.yaml

@ -0,0 +1,26 @@
# Copyright (c) 2023. Open Mobile Platform LLC.
# License: Proprietary.
name: path_provider_aurora_example
description: Demonstrates how to use the path_provider_aurora plugin.
publish_to: 'none'
environment:
sdk: '>=2.18.6 <3.0.0'
dependencies:
flutter:
sdk: flutter
path_provider: ^2.0.7
path_provider_aurora:
path: ../
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true

91
packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart

@ -0,0 +1,91 @@
/*
* Copyright (c) 2023. Open Mobile Platform LLC.
* License: Proprietary.
*/
import 'package:package_info_plus_aurora/package_info_plus_aurora.dart';
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
import 'package:xdga_directories/xdga_directories.dart' as xdga_directories;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as p;
/// The aurora implementation of [PathProviderPlatform]
///
/// This class implements the `package:path_provider` functionality for Aurora.
class PathProviderAurora extends PathProviderPlatform {
/// Registers this class as the default instance of [PathProviderPlatform]
static void registerWith() {
if (TargetPlatform.aurora == defaultTargetPlatform) {
PackageInfoPlusAurora.registerWith();
PathProviderPlatform.instance = PathProviderAurora();
}
}
/// Path to a directory where the application may place application support files.
@override
Future<String?> getApplicationSupportPath() async {
PackageInfo info = await PackageInfo.fromPlatform();
// QStandardPaths::AppDataLocation
return p.join(
xdga_directories.getAppDataLocation(),
info.packageName,
info.appName,
);
}
/// Path to the temporary directory on the device that is not backed up and is
/// suitable for storing caches of downloaded files.
@override
Future<String> getTemporaryPath() async {
PackageInfo info = await PackageInfo.fromPlatform();
// QStandardPaths::CacheLocation
return p.join(
xdga_directories.getCacheLocation(),
info.packageName,
info.appName,
);
}
/// Path to a directory where the application may place data that is
/// user-generated, or that cannot otherwise be recreated by your application.
@override
Future<String> getApplicationDocumentsPath() async {
// QStandardPaths::DocumentsLocation
return xdga_directories.getDocumentsLocation();
}
/// Path to the directory where downloaded files can be stored.
/// This is typically only relevant on desktop operating systems.
@override
Future<String> getDownloadsPath() async {
// QStandardPaths::DownloadLocation
return xdga_directories.getDownloadLocation();
}
/// Paths to directories where application specific data can be stored.
/// These paths typically reside on external storage like separate partitions
/// or SD cards. Phones may have multiple storage directories available.
@override
Future<List<String>?> getExternalStoragePaths({
/// Optional parameter. See [StorageDirectory] for more informations on
/// how this type translates to Android storage directories.
StorageDirectory? type,
}) async {
switch (type) {
case StorageDirectory.pictures:
return [
xdga_directories.getPicturesLocation()
]; // QStandardPaths::PicturesLocation
case StorageDirectory.music:
return [
xdga_directories.getMusicLocation()
]; // QStandardPaths::MusicLocation
case StorageDirectory.movies:
return [
xdga_directories.getMoviesLocation()
]; // QStandardPaths::MoviesLocation
default:
throw UnimplementedError('Type "$type" not supported.');
}
}
}

40
packages/path_provider/path_provider_aurora/pubspec.yaml

@ -0,0 +1,40 @@
# Copyright (c) 2023. Open Mobile Platform LLC.
# License: Proprietary.
name: path_provider_aurora
description: The Aurora OS implementation of path_provider.
version: 0.0.1
environment:
sdk: '>=2.18.6 <3.0.0'
flutter: ">=2.5.0"
dependencies:
flutter:
sdk: flutter
path: ^1.8.2
plugin_platform_interface: ^2.0.2
path_provider_platform_interface: ^2.0.6
xdga_directories:
git:
url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git
ref: dev
path: packages/xdga_directories
package_info_plus: 4.0.0
package_info_plus_aurora:
git:
url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git
ref: dev
path: packages/package_info_plus/package_info_plus_aurora
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
plugin:
implements: path_provider
platforms:
aurora:
dartPluginClass: PathProviderAurora
Loading…
Cancel
Save