mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-23 17:11:23 +00:00

* chore: env config * chore: get user workspace * feat: enable postgres storage * chore: add new env * chore: add set env ffi * chore: pass env before backend init * chore: update * fix: ci tests * chore: commit the generate env file * chore: remove unused import
45 lines
1.1 KiB
Dart
45 lines
1.1 KiB
Dart
export 'package:async/async.dart';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'dart:async';
|
|
import 'package:appflowy_backend/rust_stream.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'dart:ffi';
|
|
import 'env_serde.dart';
|
|
import 'ffi.dart' as ffi;
|
|
import 'package:ffi/ffi.dart';
|
|
|
|
enum ExceptionType {
|
|
AppearanceSettingsIsEmpty,
|
|
}
|
|
|
|
class FlowySDKException implements Exception {
|
|
ExceptionType type;
|
|
FlowySDKException(this.type);
|
|
}
|
|
|
|
class FlowySDK {
|
|
static const MethodChannel _channel = MethodChannel('appflowy_backend');
|
|
static Future<String> get platformVersion async {
|
|
final String version = await _channel.invokeMethod('getPlatformVersion');
|
|
return version;
|
|
}
|
|
|
|
FlowySDK();
|
|
|
|
void dispose() {}
|
|
|
|
Future<void> init(Directory sdkDir) async {
|
|
final port = RustStreamReceiver.shared.port;
|
|
ffi.set_stream_port(port);
|
|
|
|
ffi.store_dart_post_cobject(NativeApi.postCObject);
|
|
ffi.init_sdk(sdkDir.path.toNativeUtf8());
|
|
}
|
|
|
|
void setEnv(AppFlowyEnv env) {
|
|
final jsonStr = jsonEncode(env.toJson());
|
|
ffi.set_env(jsonStr.toNativeUtf8());
|
|
}
|
|
}
|