Set FLET_APP_DATA and FLET_APP_TEMP dirs for the app
This commit is contained in:
parent
e323b2f814
commit
751b719983
|
|
@ -5,7 +5,9 @@ import 'package:flet/flet.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
import 'package:path_provider/path_provider.dart' as path_provider;
|
||||||
import 'package:serious_python/serious_python.dart';
|
import 'package:serious_python/serious_python.dart';
|
||||||
import 'package:url_strategy/url_strategy.dart';
|
import 'package:url_strategy/url_strategy.dart';
|
||||||
|
|
||||||
|
|
@ -161,6 +163,26 @@ Future prepareApp() async {
|
||||||
|
|
||||||
assetsDir = path.join(appDir, "assets");
|
assetsDir = path.join(appDir, "assets");
|
||||||
|
|
||||||
|
// configure apps DATA and TEMP directories
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
var appTempPath = (await path_provider.getApplicationCacheDirectory()).path;
|
||||||
|
var appDataPath =
|
||||||
|
(await path_provider.getApplicationDocumentsDirectory()).path;
|
||||||
|
|
||||||
|
if (defaultTargetPlatform != TargetPlatform.iOS &&
|
||||||
|
defaultTargetPlatform != TargetPlatform.android) {
|
||||||
|
// append app name to the path and create dir
|
||||||
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
appDataPath = path.join(appDataPath, "flet", packageInfo.packageName);
|
||||||
|
if (!await Directory(appDataPath).exists()) {
|
||||||
|
await Directory(appDataPath).create(recursive: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
environmentVariables["FLET_APP_DATA"] = appDataPath;
|
||||||
|
environmentVariables["FLET_APP_TEMP"] = appTempPath;
|
||||||
|
|
||||||
environmentVariables["FLET_PLATFORM"] =
|
environmentVariables["FLET_PLATFORM"] =
|
||||||
defaultTargetPlatform.name.toLowerCase();
|
defaultTargetPlatform.name.toLowerCase();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,11 @@ dependencies:
|
||||||
path: ^1.9.0
|
path: ^1.9.0
|
||||||
url_strategy: ^0.2.0
|
url_strategy: ^0.2.0
|
||||||
cupertino_icons: ^1.0.6
|
cupertino_icons: ^1.0.6
|
||||||
|
path_provider: ^2.1.4
|
||||||
|
package_info_plus: ^8.0.2
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
wakelock_plus: ^1.2.5
|
wakelock_plus: ^1.2.5
|
||||||
package_info_plus: ^8.0.0
|
|
||||||
web: ^1.0.0
|
web: ^1.0.0
|
||||||
|
|
||||||
# {% if 'flet_audio_recorder' in cookiecutter.flutter.dependencies %}
|
# {% if 'flet_audio_recorder' in cookiecutter.flutter.dependencies %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue