Untitled
unknown
plain_text
2 years ago
2.6 kB
8
Indexable
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_demo_liveness/liveness_view_controller.dart';
typedef void LivenessViewCreatedCallback(LivenessViewController controller);
class LivenessNativeView extends StatefulWidget {
static const ROUTE_NAME = 'LivenessNativeView';
LivenessViewCreatedCallback livenessViewCreatedCallback;
LivenessNativeView({super.key, required this.livenessViewCreatedCallback});
@override
State<LivenessNativeView> createState() => _LivenessNativeViewState();
}
class _LivenessNativeViewState extends State<LivenessNativeView> {
static const TAG = 'LivenessNativeView';
@override
Widget build(BuildContext context) {
const String viewType = 'liveness_native_view';
Map<String, dynamic> creationParams = <String, dynamic>{
// "initString": "Move face to camera",
// "normal": "Look forward",
// "faceLeft": "Face left",
// "faceRight": "Face right",
// "faceUp": "Face up",
// "faceDown": "Face down",
// "blink": "Blink",
// "sessionToken": "sessionToken"
"color": "#CCCCCC",
"faceUp": "Ngửa mặt",
"faceDown": "Cúi mặt",
"faceLeft": "Quay trái",
"faceRight": "Quay phải",
"blink": "Nháy mắt",
"normal": "Nhìn thẳng",
"initString": "Đưa khuôn mặt vào trong camera, giữ trong 3 giây",
"sessionToken":
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYW0iOiJjMWM5N2E2MGU4ZmUiLCJpYXQiOjE2OTQ3NTYwNzEyNzMsImV4cCI6MTY5NDc1NjQzMTI3M30.z0ep_yDjxD5jCp8F_6wZLtF18DxI3AYryh6EKKaqBEE",
"urlConfig": "https://dev-gateway.ekyc.dev/burma/sdk/config",
};
if (defaultTargetPlatform == TargetPlatform.android) {
return AndroidView(
viewType: viewType,
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
onPlatformViewCreated: _onPlatformViewCreated,
);
} else {
return UiKitView(
viewType: viewType,
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
onPlatformViewCreated: _onPlatformViewCreated,
);
}
}
void _onPlatformViewCreated(int id) {
if (widget.livenessViewCreatedCallback == null) {
return;
}
widget.livenessViewCreatedCallback(LivenessViewController(id));
}
}
Editor is loading...