2021-06-19 23:41:19 +08:00
|
|
|
export 'package:async/async.dart';
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:async';
|
2021-07-07 22:24:26 +08:00
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
import 'package:flowy_sdk/dispatch/flowy_error.dart';
|
2021-06-19 23:41:19 +08:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'dart:ffi';
|
|
|
|
import 'ffi/ffi.dart' as ffi;
|
|
|
|
import 'package:ffi/ffi.dart';
|
|
|
|
|
2021-07-07 22:24:26 +08:00
|
|
|
import 'package:flowy_sdk/protobuf.dart';
|
|
|
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
|
|
|
|
2021-06-19 23:41:19 +08:00
|
|
|
class FlowySDK {
|
|
|
|
static const MethodChannel _channel = MethodChannel('flowy_sdk');
|
|
|
|
static Future<String> get platformVersion async {
|
|
|
|
final String version = await _channel.invokeMethod('getPlatformVersion');
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
const FlowySDK();
|
|
|
|
|
2021-07-03 14:14:10 +08:00
|
|
|
void dispose() {}
|
2021-06-19 23:41:19 +08:00
|
|
|
|
|
|
|
Future<void> init(Directory sdkDir) async {
|
|
|
|
ffi.store_dart_post_cobject(NativeApi.postCObject);
|
2021-07-03 14:14:10 +08:00
|
|
|
|
2021-06-19 23:41:19 +08:00
|
|
|
ffi.init_sdk(sdkDir.path.toNativeUtf8());
|
2021-07-07 22:24:26 +08:00
|
|
|
|
|
|
|
final params = UserSignInParams.create();
|
|
|
|
params.email = "nathan.fu@gmail.com";
|
|
|
|
params.password = "Helloworld!2";
|
|
|
|
Either<UserSignInResult, FlowyError> resp =
|
|
|
|
await UserEventSignIn(params).send();
|
|
|
|
|
|
|
|
resp.fold(
|
|
|
|
(result) {
|
|
|
|
print(result);
|
|
|
|
},
|
|
|
|
(error) {
|
|
|
|
print(error);
|
|
|
|
},
|
|
|
|
);
|
2021-06-19 23:41:19 +08:00
|
|
|
}
|
|
|
|
}
|