From 71f7a3031840e372203ecf0311aadf36e8cfe88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 22 Jan 2024 14:38:01 +0100 Subject: [PATCH] chore: apply refactoring changes according to lints --- integration_test/app_test.dart | 3 +-- lib/api/wallet.dart | 5 +++-- lib/util/graphs.dart | 1 + lib/views/create_entry.dart | 4 +++- lib/views/create_recur_entry.dart | 4 +++- lib/views/home.dart | 1 + lib/views/settings/edit_categories.dart | 4 ++-- lib/views/settings/graph_type.dart | 8 ++++---- lib/views/settings/tessdata_list.dart | 4 +++- 9 files changed, 21 insertions(+), 13 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 5450523..fd707c7 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -111,8 +111,7 @@ void main() { ); }); - testWidgets('Test correct rendering of entries', - (WidgetTester tester) async { + testWidgets('Test rendering of entries', (WidgetTester tester) async { // Delete all data await WalletManager.deleteAllData(); expect((await WalletManager.listWallets()).length, equals(0)); diff --git a/lib/api/wallet.dart b/lib/api/wallet.dart index fc0cc8b..8440b51 100644 --- a/lib/api/wallet.dart +++ b/lib/api/wallet.dart @@ -136,7 +136,8 @@ class Wallet { : recurringEntries[recurringEntries.indexOf(ent)].lastRunDate.day, ); // add the variable again to check if we aren't missing any entries logger.i( - "Last recurred date is now on ${DateFormat.yMMMMd().format(m)} (${n.isAfter(m)})"); + "Last recurred date is now on ${DateFormat.yMMMMd().format(m)} (${n.isAfter(m)})", + ); } WalletManager.saveWallet(this); // save wallet } @@ -173,7 +174,7 @@ class Wallet { fontFamily: 'MaterialIcons', ), color: Colors.white, - ) + ), ], currency: Currency.from( json: { diff --git a/lib/util/graphs.dart b/lib/util/graphs.dart index 2ccd5e5..211ee90 100644 --- a/lib/util/graphs.dart +++ b/lib/util/graphs.dart @@ -522,6 +522,7 @@ class Indicator extends StatelessWidget { /// Text shown next to the indicator circle final String text; + /// Text style of the indicator final TextStyle textStyle; @override diff --git a/lib/views/create_entry.dart b/lib/views/create_entry.dart index 1b27c8c..76320f9 100644 --- a/lib/views/create_entry.dart +++ b/lib/views/create_entry.dart @@ -192,7 +192,9 @@ class _CreateSingleEntryViewState extends State { onPressed: () { if (newEntry.data.name.isEmpty) { showMessage( - AppLocalizations.of(context).errorEmptyName, context); + AppLocalizations.of(context).errorEmptyName, + context, + ); return; } if (widget.editEntry != null) { diff --git a/lib/views/create_recur_entry.dart b/lib/views/create_recur_entry.dart index 1ad51a6..be03897 100644 --- a/lib/views/create_recur_entry.dart +++ b/lib/views/create_recur_entry.dart @@ -315,7 +315,9 @@ class _CreateRecurringEntryViewState extends State { onPressed: () { if (newEntry.data.name.isEmpty) { showMessage( - AppLocalizations.of(context).errorEmptyName, context); + AppLocalizations.of(context).errorEmptyName, + context, + ); return; } if (widget.editEntry != null) { diff --git a/lib/views/home.dart b/lib/views/home.dart index ab0a45f..a7606a4 100644 --- a/lib/views/home.dart +++ b/lib/views/home.dart @@ -490,6 +490,7 @@ class _HomeViewState extends State { } description.write("${line.replaceAll(regex, "")}\n"); } + if (!ctx.mounted) return; Navigator.of(ctx).pop(); // show edit final newEntry = diff --git a/lib/views/settings/edit_categories.dart b/lib/views/settings/edit_categories.dart index 832234d..757c87b 100644 --- a/lib/views/settings/edit_categories.dart +++ b/lib/views/settings/edit_categories.dart @@ -146,7 +146,7 @@ class _EditCategoriesViewState extends State { (await SharedPreferences.getInstance()) .getBool("useMaterialYou") ?? false; - if (!mounted) return; + if (!context.mounted) return; await showDialog( context: context, builder: (c) => PlatformDialog( @@ -227,7 +227,7 @@ class _EditCategoriesViewState extends State { await WalletManager.saveWallet( selectedWallet!, ); - if (!mounted) return; + if (!context.mounted) return; Navigator.of(context).pop(); }, child: Text( diff --git a/lib/views/settings/graph_type.dart b/lib/views/settings/graph_type.dart index cc5d57e..2d7c48b 100644 --- a/lib/views/settings/graph_type.dart +++ b/lib/views/settings/graph_type.dart @@ -70,7 +70,7 @@ class _GraphTypeSettingsViewState extends State { final s = await SharedPreferences.getInstance(); await s.setInt("yearlygraph", 1); _yearly = 1; - if (!mounted) return; + if (!ctx.mounted) return; Navigator.of(ctx).pop(); setState(() {}); }, @@ -90,7 +90,7 @@ class _GraphTypeSettingsViewState extends State { final s = await SharedPreferences.getInstance(); await s.setInt("yearlygraph", 2); _yearly = 2; - if (!mounted) return; + if (!ctx.mounted) return; Navigator.of(ctx).pop(); setState(() {}); }, @@ -128,7 +128,7 @@ class _GraphTypeSettingsViewState extends State { final s = await SharedPreferences.getInstance(); await s.setInt("monthlygraph", 1); _monthly = 1; - if (!mounted) return; + if (!ctx.mounted) return; Navigator.of(ctx).pop(); setState(() {}); }, @@ -148,7 +148,7 @@ class _GraphTypeSettingsViewState extends State { final s = await SharedPreferences.getInstance(); await s.setInt("monthlygraph", 2); _monthly = 2; - if (!mounted) return; + if (!ctx.mounted) return; Navigator.of(ctx).pop(); setState(() {}); }, diff --git a/lib/views/settings/tessdata_list.dart b/lib/views/settings/tessdata_list.dart index a0648a5..855202c 100644 --- a/lib/views/settings/tessdata_list.dart +++ b/lib/views/settings/tessdata_list.dart @@ -75,7 +75,9 @@ class _TessdataListViewState extends State { onPressed: () async { await TessdataApi.deleteData(lang); _tessdata[i][lang] = true; - if (mounted) Navigator.of(context).pop(); + if (context.mounted) { + Navigator.of(context).pop(); + } }, ), PlatformButton(