Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor showSnackbar to fix lint on latest flutter #1214

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mobile/lib/common/snack_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
/// Show a snackbar with the given message
///
/// Extracted as a separate function to ensure consistent style of error messages
void showSnackBar(BuildContext context, String message) {
void showSnackBar(ScaffoldMessengerState messenger, String message) {
final snackBar = SnackBar(content: Text(message));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
messenger.showSnackBar(snackBar);
}
6 changes: 3 additions & 3 deletions mobile/lib/features/wallet/share_invoice_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,14 @@ class _ShareInvoiceScreenState extends State<ShareInvoiceScreen> {
});

final router = GoRouter.of(context);
final messenger = ScaffoldMessenger.of(context);
try {
await payInvoiceWithFaucet(widget.invoice.rawInvoice);
// Pop both create invoice screen and share invoice screen
router.pop();
router.pop();
} catch (error) {
showSnackBar(context, error.toString());
showSnackBar(messenger, error.toString());
} finally {
setState(() {
_isPayInvoiceButtonDisabled = false;
Expand All @@ -158,8 +159,7 @@ class _ShareInvoiceScreenState extends State<ShareInvoiceScreen> {
child: OutlinedButton(
onPressed: () {
Clipboard.setData(ClipboardData(text: widget.invoice.rawInvoice)).then((_) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Invoice copied to clipboard')));
showSnackBar(ScaffoldMessenger.of(context), "Invoice copied to clipboard");
});
},
style: ElevatedButton.styleFrom(
Expand Down
3 changes: 2 additions & 1 deletion mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:get_10101/common/channel_status_notifier.dart';
import 'package:get_10101/common/color.dart';
import 'package:get_10101/common/domain/service_status.dart';
import 'package:get_10101/common/service_status_notifier.dart';
import 'package:get_10101/common/snack_bar.dart';
import 'package:get_10101/features/stable/stable_screen.dart';
import 'package:get_10101/features/trade/application/candlestick_service.dart';
import 'package:get_10101/features/trade/application/order_service.dart';
Expand Down Expand Up @@ -265,7 +266,7 @@ class _TenTenOneAppState extends State<TenTenOneApp> {
}
} catch (e) {
FLog.error(text: "Error getting coordinator version: ${e.toString()}");
messenger.showSnackBar(const SnackBar(content: Text("Coordinator offline")));
showSnackBar(messenger, "Coordinator offline");
}
});
}
Expand Down