bl_wallet_native 0.0.1
bl_wallet_native: ^0.0.1 copied to clipboard
BL Wallet Native Code Plugin
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:bl_wallet_native/bl_wallet_native.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _initTrustWallet = 'Unknown';
final _blWalletNativePlugin = BlWalletNative();
@override
void initState() {
super.initState();
initTrustWallet();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initTrustWallet() async {
String initTrustWallet;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
initTrustWallet =
await _blWalletNativePlugin.initTrustWallet() ?? 'Unknown Trust Wallet';
} on PlatformException {
initTrustWallet = 'Failed to init trust wallet';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_initTrustWallet = initTrustWallet;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('BL Wallet Native Plugin'),
),
body: Center(
child: Text('init: $_initTrustWallet\n'),
),
),
);
}
}