From 762ec18b49792c96e640b152c9a7b50909fe8edd Mon Sep 17 00:00:00 2001 From: Alfreedom <00tango.bromine@icloud.com> Date: Tue, 17 Oct 2023 16:36:53 +0200 Subject: [PATCH] fixed lint errors --- example/dapp/lib/main.dart | 2 +- example/dapp/lib/pages/connect_page.dart | 55 +++++++------------ example/dapp/lib/widgets/method_dialog.dart | 35 ++++-------- .../lib/dependencies/chains/evm_service.dart | 8 +-- example/wallet/lib/main.dart | 2 +- 5 files changed, 38 insertions(+), 64 deletions(-) diff --git a/example/dapp/lib/main.dart b/example/dapp/lib/main.dart index d1e47a99..d238b565 100644 --- a/example/dapp/lib/main.dart +++ b/example/dapp/lib/main.dart @@ -60,7 +60,7 @@ class _MyHomePageState extends State { Future initialize() async { // try { - print('Project ID: ${DartDefines.projectId}'); + debugPrint('Project ID: ${DartDefines.projectId}'); _web3App = await Web3App.createInstance( projectId: DartDefines.projectId, logLevel: LogLevel.info, diff --git a/example/dapp/lib/pages/connect_page.dart b/example/dapp/lib/pages/connect_page.dart index 8e14a9bd..9940b946 100644 --- a/example/dapp/lib/pages/connect_page.dart +++ b/example/dapp/lib/pages/connect_page.dart @@ -73,7 +73,12 @@ class ConnectPageState extends State { vertical: StyleConstants.linear8, ), child: ElevatedButton( - onPressed: () => _onConnect(_selectedChains), + onPressed: () => _onConnect( + _selectedChains, + showToast: (m) async { + await showPlatformToast(child: Text(m), context: context); + }, + ), style: ButtonStyle( backgroundColor: MaterialStateProperty.all( StyleConstants.primaryColor, @@ -155,9 +160,8 @@ class ConnectPageState extends State { ); } - Future _onConnect( - List chains, - ) async { + Future _onConnect(List chains, + {Function(String message)? showToast}) async { // Use the chain metadata to build the required namespaces: // Get the methods, get the events final Map requiredNamespaces = {}; @@ -192,12 +196,7 @@ class ConnectPageState extends State { final _ = await res.session.future; // print(sessionData); - showPlatformToast( - child: const Text( - StringConstants.connectionEstablished, - ), - context: context, - ); + showToast?.call(StringConstants.connectionEstablished); // Send off an auth request now that the pairing/session is established debugPrint('Requesting authentication'); @@ -216,19 +215,9 @@ class ConnectPageState extends State { if (authResponse.error != null) { debugPrint('Authentication failed: ${authResponse.error}'); - await showPlatformToast( - child: const Text( - StringConstants.authFailed, - ), - context: context, - ); + showToast?.call(StringConstants.authFailed); } else { - showPlatformToast( - child: const Text( - StringConstants.authSucceeded, - ), - context: context, - ); + showToast?.call(StringConstants.authSucceeded); } if (_shouldDismissQrCode) { @@ -241,12 +230,7 @@ class ConnectPageState extends State { // ignore: use_build_context_synchronously Navigator.pop(context); } - await showPlatformToast( - child: const Text( - StringConstants.connectionFailed, - ), - context: context, - ); + showToast?.call(StringConstants.connectionFailed); } } @@ -279,17 +263,18 @@ class ConnectPageState extends State { height: StyleConstants.linear16, ), ElevatedButton( - onPressed: () async { - await Clipboard.setData( + onPressed: () { + Clipboard.setData( ClipboardData( text: response.uri!.toString(), ), - ); - await showPlatformToast( - child: const Text( - StringConstants.copiedToClipboard, + ).then( + (_) => showPlatformToast( + child: const Text( + StringConstants.copiedToClipboard, + ), + context: context, ), - context: context, ); }, child: const Text( diff --git a/example/dapp/lib/widgets/method_dialog.dart b/example/dapp/lib/widgets/method_dialog.dart index a0bafed0..e745cf00 100644 --- a/example/dapp/lib/widgets/method_dialog.dart +++ b/example/dapp/lib/widgets/method_dialog.dart @@ -48,36 +48,25 @@ class MethodDialogState extends State { if (snapshot.hasData) { final String t = jsonEncode(snapshot.data); return InkWell( - onTap: () async { - await Clipboard.setData( - ClipboardData( - text: t, + onTap: () { + Clipboard.setData(ClipboardData(text: t)).then( + (_) => showPlatformToast( + child: const Text(StringConstants.copiedToClipboard), + context: context, ), ); - showPlatformToast( - child: const Text( - StringConstants.copiedToClipboard, - ), - context: context, - ); }, - child: Text( - t, - ), + child: Text(t), ); } else if (snapshot.hasError) { return InkWell( - onTap: () async { - await Clipboard.setData( - ClipboardData( - text: snapshot.data.toString(), - ), - ); - showPlatformToast( - child: const Text( - StringConstants.copiedToClipboard, + onTap: () { + Clipboard.setData(ClipboardData(text: snapshot.data.toString())) + .then( + (_) => showPlatformToast( + child: const Text(StringConstants.copiedToClipboard), + context: context, ), - context: context, ); }, child: Text( diff --git a/example/wallet/lib/dependencies/chains/evm_service.dart b/example/wallet/lib/dependencies/chains/evm_service.dart index 2b8f2827..796f5a3f 100644 --- a/example/wallet/lib/dependencies/chains/evm_service.dart +++ b/example/wallet/lib/dependencies/chains/evm_service.dart @@ -247,24 +247,24 @@ class EVMService extends IChain { final transaction = Transaction( from: EthereumAddress.fromHex(ethTransaction.from), to: EthereumAddress.fromHex(ethTransaction.to), - value: EtherAmount.fromUnitAndValue( + value: EtherAmount.fromBigInt( EtherUnit.wei, BigInt.tryParse(ethTransaction.value) ?? BigInt.zero, ), gasPrice: ethTransaction.gasPrice != null - ? EtherAmount.fromUnitAndValue( + ? EtherAmount.fromBigInt( EtherUnit.wei, BigInt.tryParse(ethTransaction.gasPrice!) ?? BigInt.zero, ) : null, maxFeePerGas: ethTransaction.maxFeePerGas != null - ? EtherAmount.fromUnitAndValue( + ? EtherAmount.fromBigInt( EtherUnit.wei, BigInt.tryParse(ethTransaction.maxFeePerGas!) ?? BigInt.zero, ) : null, maxPriorityFeePerGas: ethTransaction.maxPriorityFeePerGas != null - ? EtherAmount.fromUnitAndValue( + ? EtherAmount.fromBigInt( EtherUnit.wei, BigInt.tryParse(ethTransaction.maxPriorityFeePerGas!) ?? BigInt.zero, diff --git a/example/wallet/lib/main.dart b/example/wallet/lib/main.dart index 9dc5ce25..1e50c7f1 100644 --- a/example/wallet/lib/main.dart +++ b/example/wallet/lib/main.dart @@ -39,7 +39,7 @@ class MyApp extends StatelessWidget { const nearWhite = Color(0xFFE0E0E0); return baseTheme.copyWith( - backgroundColor: Colors.black, + colorScheme: ColorScheme.fromSeed(seedColor: Colors.black), scaffoldBackgroundColor: Colors.black, textTheme: baseTheme.textTheme.apply( bodyColor: nearWhite,