| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							| 
									
										
										
										
											2021-10-11 13:15:41 +08:00
										 |  |  | import 'package:app_flowy/startup/launcher.dart'; | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08: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'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 { | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |     WidgetsFlutterBinding.ensureInitialized(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-03 21:40:13 +08:00
										 |  |  |     Directory directory = await getApplicationDocumentsDirectory(); | 
					
						
							|  |  |  |     final documentPath = directory.path; | 
					
						
							| 
									
										
										
										
											2021-07-12 23:27:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-11 13:15:41 +08:00
										 |  |  |     return Directory('$documentPath/flowy').create().then((Directory directory) async { | 
					
						
							| 
									
										
										
										
											2021-07-29 17:46:20 +08: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 23:41:19 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } |