Skip to content

Commit

Permalink
chore: remove Future.microtask() use (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-tbd authored Aug 15, 2024
1 parent 6f00a1f commit ba16924
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/features/account/account_balance_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class AccountBalanceCard extends HookConsumerWidget {

useEffect(
() {
Future.microtask(
Future.delayed(
Duration.zero,
() async => getAccountBalanceNotifier()
.startPolling(ref.read(didProvider), pfis),
);
Expand Down
3 changes: 2 additions & 1 deletion lib/features/dap/dap_qr_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class DapQrTile extends HookConsumerWidget {

useEffect(
() {
Future.microtask(
Future.delayed(
Duration.zero,
() async => isPhysicalDevice.value =
await ref.read(deviceInfoServiceProvider).isPhysicalDevice(),
);
Expand Down
3 changes: 2 additions & 1 deletion lib/features/did/did_qr_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class DidQrTile extends HookConsumerWidget {

useEffect(
() {
Future.microtask(
Future.delayed(
Duration.zero,
() async => isPhysicalDevice.value =
await ref.read(deviceInfoServiceProvider).isPhysicalDevice(),
);
Expand Down
3 changes: 2 additions & 1 deletion lib/features/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class HomePage extends HookConsumerWidget {

useEffect(
() {
Future.microtask(() async => _getExchanges(context, ref, exchanges));
Future.delayed(
Duration.zero, () async => _getExchanges(context, ref, exchanges),);
return null;
},
[],
Expand Down
3 changes: 2 additions & 1 deletion lib/features/kcc/kcc_retrieval_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class KccRetrievalPage extends HookConsumerWidget {

useEffect(
() {
Future.microtask(
Future.delayed(
Duration.zero,
() async => _pollForCredential(context, ref, credential),
);

Expand Down
3 changes: 2 additions & 1 deletion lib/features/kcc/kcc_webview_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class KccWebviewPage extends HookConsumerWidget {

useEffect(
() {
Future.microtask(
Future.delayed(
Duration.zero,
() async => _loadWebView(context, ref, idvRequest, webViewController),
);
return null;
Expand Down
5 changes: 3 additions & 2 deletions lib/features/payment/payment_amount_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class PaymentAmountPage extends HookConsumerWidget {

useEffect(
() {
Future.microtask(
() async => _getOfferings(context, ref, offerings),
Future.delayed(
Duration.zero,
() => _getOfferings(context, ref, offerings),
);
return null;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PaymentFetchInstructionsWidget extends HookWidget {

useEffect(
() {
Future.microtask(() async {
Future.delayed(Duration.zero, () async {
if (context.mounted) {
await _pollForInstructions(context, ref, getInstructionsNotifier());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/features/payment/payment_fetch_quote_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentFetchQuoteWidget extends HookWidget {

useEffect(
() {
Future.microtask(() async {
Future.delayed(Duration.zero, () async {
if (context.mounted) {
await _pollForQuote(context, ref, getQuoteNotifier());
}
Expand Down
5 changes: 4 additions & 1 deletion lib/features/transaction/transaction_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class TransactionTile extends HookConsumerWidget {

useEffect(
() {
Future.microtask(() async => getTransactionsNotifier().startPolling());
Future.delayed(
Duration.zero,
() async => getTransactionsNotifier().startPolling(),
);
return getTransactionsNotifier().stopPolling;
},
[],
Expand Down
1 change: 1 addition & 0 deletions test/features/app/app_tabs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void main() async {

testWidgets('should start on HomePage', (tester) async {
await tester.pumpWidget(appTabsTestWidget());
await tester.pumpAndSettle();

expect(find.byType(HomePage), findsOneWidget);
});
Expand Down
3 changes: 3 additions & 0 deletions test/features/home/home_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void main() async {

testWidgets('should show account balance', (tester) async {
await tester.pumpWidget(homePageTestWidget());
await tester.pumpAndSettle();

expect(find.text('Account balance'), findsOneWidget);
});
Expand All @@ -87,12 +88,14 @@ void main() async {

testWidgets('should show deposit button', (tester) async {
await tester.pumpWidget(homePageTestWidget());
await tester.pumpAndSettle();

expect(find.widgetWithText(FilledButton, 'Deposit'), findsOneWidget);
});

testWidgets('should show withdraw button', (tester) async {
await tester.pumpWidget(homePageTestWidget());
await tester.pumpAndSettle();

expect(find.widgetWithText(FilledButton, 'Withdraw'), findsOneWidget);
});
Expand Down
3 changes: 3 additions & 0 deletions test/features/pfis/pfis_add_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void main() {

testWidgets('should show QR Code CTA', (tester) async {
await tester.pumpWidget(pfisAddPageTestWidget());
await tester.pumpAndSettle();

expect(
find.widgetWithText(
Expand All @@ -25,12 +26,14 @@ void main() {

testWidgets('should show input field', (tester) async {
await tester.pumpWidget(pfisAddPageTestWidget());
await tester.pumpAndSettle();

expect(find.byType(TextField), findsOneWidget);
});

testWidgets('should show add button', (tester) async {
await tester.pumpWidget(pfisAddPageTestWidget());
await tester.pumpAndSettle();

expect(find.widgetWithText(FilledButton, 'Add'), findsOneWidget);
});
Expand Down
3 changes: 3 additions & 0 deletions test/features/send/send_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void main() async {

testWidgets('should show QR Code CTA', (tester) async {
await tester.pumpWidget(sendDetailsPageTestWidget());
await tester.pumpAndSettle();

expect(
find.widgetWithText(
Expand All @@ -43,12 +44,14 @@ void main() async {

testWidgets('should show input field', (tester) async {
await tester.pumpWidget(sendDetailsPageTestWidget());
await tester.pumpAndSettle();

expect(find.byType(TextField), findsOneWidget);
});

testWidgets('should show next button', (tester) async {
await tester.pumpWidget(sendDetailsPageTestWidget());
await tester.pumpAndSettle();

expect(find.widgetWithText(FilledButton, 'Next'), findsOneWidget);
});
Expand Down

0 comments on commit ba16924

Please sign in to comment.