AppFlowy/app_flowy/lib/startup/tasks/sdk_task.dart

34 lines
1.1 KiB
Dart
Raw Normal View History

2021-06-19 15:41:19 +00:00
import 'dart:io';
2021-10-11 05:15:41 +00:00
import 'package:app_flowy/startup/launcher.dart';
2021-06-19 15:41:19 +00:00
import 'package:app_flowy/startup/startup.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flowy_sdk/flowy_sdk.dart';
import 'package:flutter/material.dart';
class RustSDKInitTask extends LaunchTask {
@override
LaunchTaskType get type => LaunchTaskType.dataProcessing;
@override
2021-07-12 15:27:58 +00:00
Future<void> initialize(LaunchContext context) async {
2021-06-19 15:41:19 +00:00
WidgetsFlutterBinding.ensureInitialized();
2021-07-03 13:40:13 +00:00
Directory directory = await getApplicationDocumentsDirectory();
final documentPath = directory.path;
2021-07-12 15:27:58 +00:00
2021-10-11 05:15:41 +00:00
return Directory('$documentPath/flowy').create().then((Directory directory) async {
2021-07-29 09:46:20 +00:00
switch (context.env) {
case IntegrationEnv.dev:
// await context.getIt<FlowySDK>().init(Directory('./temp/flowy_dev'));
await context.getIt<FlowySDK>().init(directory);
break;
case IntegrationEnv.pro:
await context.getIt<FlowySDK>().init(directory);
break;
default:
assert(false, 'Unsupported env');
}
});
2021-06-19 15:41:19 +00:00
}
}