| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							|  |  |  | import 'package:app_flowy/startup/startup.dart'; | 
					
						
							|  |  |  | import 'package:path_provider/path_provider.dart'; | 
					
						
							|  |  |  | import 'package:flowy_sdk/flowy_sdk.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 22:24:32 +08:00
										 |  |  | class InitRustSDKTask extends LaunchTask { | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   LaunchTaskType get type => LaunchTaskType.dataProcessing; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2021-07-12 23:27:58 +08:00
										 |  |  |   Future<void> initialize(LaunchContext context) async { | 
					
						
							| 
									
										
										
										
											2022-04-28 20:54:04 +08:00
										 |  |  |     await appFlowyDocumentDirectory().then((directory) async { | 
					
						
							|  |  |  |       await context.getIt<FlowySDK>().init(directory); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Future<Directory> appFlowyDocumentDirectory() async { | 
					
						
							|  |  |  |   Directory documentsDir = await getApplicationDocumentsDirectory(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (integrationEnv()) { | 
					
						
							|  |  |  |     case IntegrationMode.develop: | 
					
						
							|  |  |  |       return Directory('${documentsDir.path}/flowy_dev').create(); | 
					
						
							|  |  |  |     case IntegrationMode.release: | 
					
						
							|  |  |  |       return Directory('${documentsDir.path}/flowy').create(); | 
					
						
							|  |  |  |     case IntegrationMode.test: | 
					
						
							|  |  |  |       return Directory("${Directory.current.path}/.sandbox"); | 
					
						
							| 
									
										
										
										
											2022-02-19 23:19:33 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | } |