| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | export 'package:async/async.dart'; | 
					
						
							|  |  |  | import 'dart:async'; | 
					
						
							| 
									
										
										
										
											2023-01-08 12:10:53 +08:00
										 |  |  | import 'package:appflowy_backend/rust_stream.dart'; | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | import 'package:flutter/services.dart'; | 
					
						
							|  |  |  | import 'dart:ffi'; | 
					
						
							| 
									
										
										
										
											2021-07-13 10:59:51 +08:00
										 |  |  | import 'ffi.dart' as ffi; | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | import 'package:ffi/ffi.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-28 18:34:21 +08:00
										 |  |  | enum ExceptionType { | 
					
						
							|  |  |  |   AppearanceSettingsIsEmpty, | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FlowySDKException implements Exception { | 
					
						
							|  |  |  |   ExceptionType type; | 
					
						
							|  |  |  |   FlowySDKException(this.type); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | class FlowySDK { | 
					
						
							| 
									
										
										
										
											2023-01-08 12:10:53 +08:00
										 |  |  |   static const MethodChannel _channel = MethodChannel('appflowy_backend'); | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |   static Future<String> get platformVersion async { | 
					
						
							|  |  |  |     final String version = await _channel.invokeMethod('getPlatformVersion'); | 
					
						
							|  |  |  |     return version; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   FlowySDK(); | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-03 14:14:10 +08:00
										 |  |  |   void dispose() {} | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-20 20:54:47 +08:00
										 |  |  |   Future<void> init(String configuration) async { | 
					
						
							| 
									
										
										
										
											2021-07-21 15:43:05 +08:00
										 |  |  |     final port = RustStreamReceiver.shared.port; | 
					
						
							|  |  |  |     ffi.set_stream_port(port); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |     ffi.store_dart_post_cobject(NativeApi.postCObject); | 
					
						
							| 
									
										
										
										
											2023-11-20 20:54:47 +08:00
										 |  |  |     ffi.init_sdk(configuration.toNativeUtf8()); | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | } |