Skip to content

Commit

Permalink
fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Oct 17, 2023
1 parent 9051c01 commit 762ec18
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 64 deletions.
2 changes: 1 addition & 1 deletion example/dapp/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _MyHomePageState extends State<MyHomePage> {

Future<void> initialize() async {
// try {
print('Project ID: ${DartDefines.projectId}');
debugPrint('Project ID: ${DartDefines.projectId}');
_web3App = await Web3App.createInstance(
projectId: DartDefines.projectId,
logLevel: LogLevel.info,
Expand Down
55 changes: 20 additions & 35 deletions example/dapp/lib/pages/connect_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ class ConnectPageState extends State<ConnectPage> {
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<Color>(
StyleConstants.primaryColor,
Expand Down Expand Up @@ -155,9 +160,8 @@ class ConnectPageState extends State<ConnectPage> {
);
}

Future<void> _onConnect(
List<ChainMetadata> chains,
) async {
Future<void> _onConnect(List<ChainMetadata> chains,
{Function(String message)? showToast}) async {
// Use the chain metadata to build the required namespaces:
// Get the methods, get the events
final Map<String, RequiredNamespace> requiredNamespaces = {};
Expand Down Expand Up @@ -192,12 +196,7 @@ class ConnectPageState extends State<ConnectPage> {
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');
Expand All @@ -216,19 +215,9 @@ class ConnectPageState extends State<ConnectPage> {

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) {
Expand All @@ -241,12 +230,7 @@ class ConnectPageState extends State<ConnectPage> {
// ignore: use_build_context_synchronously
Navigator.pop(context);
}
await showPlatformToast(
child: const Text(
StringConstants.connectionFailed,
),
context: context,
);
showToast?.call(StringConstants.connectionFailed);
}
}

Expand Down Expand Up @@ -279,17 +263,18 @@ class ConnectPageState extends State<ConnectPage> {
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(
Expand Down
35 changes: 12 additions & 23 deletions example/dapp/lib/widgets/method_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,25 @@ class MethodDialogState extends State<MethodDialog> {
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(
Expand Down
8 changes: 4 additions & 4 deletions example/wallet/lib/dependencies/chains/evm_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion example/wallet/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 762ec18

Please sign in to comment.