diff --git a/analysis_options.yaml b/analysis_options.yaml index a74d9d6..894e0e4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -137,7 +137,6 @@ linter: - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_const - - unnecessary_constructor_name - unnecessary_getters_setters - unnecessary_new - unnecessary_null_aware_assignments diff --git a/lib/bloc/theme/theme_state.dart b/lib/bloc/theme/theme_state.dart index 7bb3518..7b45fbb 100644 --- a/lib/bloc/theme/theme_state.dart +++ b/lib/bloc/theme/theme_state.dart @@ -4,24 +4,22 @@ part of 'theme_bloc.dart'; abstract class ThemeState { final bool prefsAreLoaded; - const ThemeState(this.prefsAreLoaded); + const ThemeState({required this.prefsAreLoaded}); AppTheme get theme; } class LightThemeState extends ThemeState { - final bool prefsAreLoaded; - - const LightThemeState({this.prefsAreLoaded = false}) : super(prefsAreLoaded); + const LightThemeState({bool prefsAreLoaded = false}) + : super(prefsAreLoaded: prefsAreLoaded); @override AppTheme get theme => LightTheme(); } class DarkThemeState extends ThemeState { - final bool prefsAreLoaded; - - const DarkThemeState({this.prefsAreLoaded = false}) : super(prefsAreLoaded); + const DarkThemeState({bool prefsAreLoaded = false}) + : super(prefsAreLoaded: prefsAreLoaded); @override AppTheme get theme => DarkTheme(); diff --git a/lib/models/history/search.dart b/lib/models/history/search.dart index 7e3c7e6..2de2096 100644 --- a/lib/models/history/search.dart +++ b/lib/models/history/search.dart @@ -1,5 +1,4 @@ import 'package:sembast/sembast.dart'; -import 'package:sembast/timestamp.dart'; import './kanji_query.dart'; import './word_query.dart'; diff --git a/lib/models/themes/theme.dart b/lib/models/themes/theme.dart index 76369cc..705be40 100644 --- a/lib/models/themes/theme.dart +++ b/lib/models/themes/theme.dart @@ -50,7 +50,9 @@ class ColorSet { MaterialColor createMaterialColor(Color color) { final List strengths = [.05]; final swatch = {}; - final int r = color.red, g = color.green, b = color.blue; + final int r = color.red; + final int g = color.green; + final int b = color.blue; for (int i = 1; i < 10; i++) { strengths.add(0.1 * i); diff --git a/lib/router.dart b/lib/router.dart index a588e5c..ccf126a 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -12,13 +12,13 @@ Route generateRoute(RouteSettings settings) { return MaterialPageRoute(builder: (_) => const Home()); case '/search': - final searchTerm = args as String; + final searchTerm = args! as String; return MaterialPageRoute( builder: (_) => SearchResultsPage(searchTerm: searchTerm), ); case '/kanjiSearch': - final searchTerm = args as String; + final searchTerm = args! as String; return MaterialPageRoute( builder: (_) => KanjiResultPage(kanjiSearchTerm: searchTerm), ); diff --git a/lib/view/components/history/kanji_search_item.dart b/lib/view/components/history/kanji_search_item.dart index 5a9d405..582fee9 100644 --- a/lib/view/components/history/kanji_search_item.dart +++ b/lib/view/components/history/kanji_search_item.dart @@ -54,26 +54,26 @@ class KanjiSearchItem extends StatelessWidget { @override Widget build(BuildContext context) { return Slidable( - child: SearchItem( - onTap: () { - Navigator.pushNamed(context, '/kanjiSearch', arguments: this.result.kanji); - }, - time: timestamp, - search: _KanjiBox(result.kanji), - ), - actionPane: SlidableScrollActionPane(), - secondaryActions: [ + actionPane: const SlidableScrollActionPane(), + secondaryActions: const [ IconSlideAction( - caption: "Favourite", + caption: 'Favourite', color: Colors.yellow, icon: Icons.star, ), IconSlideAction( - caption: "Delete", + caption: 'Delete', color: Colors.red, icon: Icons.delete, ), ], + child: SearchItem( + onTap: () { + Navigator.pushNamed(context, '/kanjiSearch', arguments: result.kanji); + }, + time: timestamp, + search: _KanjiBox(result.kanji), + ), ); } } diff --git a/lib/view/components/kanji/kanji_search_body/kanji_search_bar.dart b/lib/view/components/kanji/kanji_search_body/kanji_search_bar.dart index 7f2ef5d..ce1b806 100644 --- a/lib/view/components/kanji/kanji_search_body/kanji_search_bar.dart +++ b/lib/view/components/kanji/kanji_search_body/kanji_search_bar.dart @@ -7,7 +7,7 @@ class KanjiSearchBar extends StatefulWidget { const KanjiSearchBar({this.onChanged, Key? key}) : super(key: key); @override - KanjiSearchBarState createState() => KanjiSearchBarState(this.onChanged); + KanjiSearchBarState createState() => KanjiSearchBarState(); } enum TextFieldButton { clear, paste } @@ -15,9 +15,6 @@ enum TextFieldButton { clear, paste } class KanjiSearchBarState extends State { final TextEditingController textController = TextEditingController(); TextFieldButton button = TextFieldButton.paste; - final Function(String)? onChanged; - - KanjiSearchBarState(this.onChanged); @override void initState() { @@ -25,7 +22,7 @@ class KanjiSearchBarState extends State { } void runOnChanged() { - if (onChanged != null) onChanged!(textController.text); + if (widget.onChanged != null) widget.onChanged!(textController.text); } void clearText() { @@ -56,7 +53,7 @@ class KanjiSearchBarState extends State { return TextField( controller: textController, onChanged: (text) { - if (onChanged != null) onChanged!(text); + if (widget.onChanged != null) widget.onChanged!(text); }, onSubmitted: (_) => {}, decoration: InputDecoration( diff --git a/lib/view/components/search/search_results_body/parts/wanikani_badge.dart b/lib/view/components/search/search_results_body/parts/wanikani_badge.dart index 3de0ec2..96df9c8 100644 --- a/lib/view/components/search/search_results_body/parts/wanikani_badge.dart +++ b/lib/view/components/search/search_results_body/parts/wanikani_badge.dart @@ -2,25 +2,27 @@ import 'package:flutter/material.dart'; import './badge.dart'; class WKBadge extends StatelessWidget { - final String wkLevel; + final String level; - const WKBadge(this.wkLevel); + const WKBadge({ + required this.level, + Key? key, + }) : super(key: key); String _extractWkLevel(String wkRaw) { - // return jlptRaw.isNotEmpty ? jlptRaw.substring(5).toUpperCase() : ''; - return wkRaw.isNotEmpty ? 'W' + wkRaw.substring(8) : ''; + return wkRaw.isNotEmpty ? 'W${wkRaw.substring(8)}' : ''; } @override Widget build(BuildContext context) { return Badge( + color: level.isNotEmpty ? Colors.red : Colors.transparent, child: Text( - _extractWkLevel(this.wkLevel), - style: TextStyle( + _extractWkLevel(level), + style: const TextStyle( color: Colors.white, ), ), - color: this.wkLevel.isNotEmpty ? Colors.red : Colors.transparent ); } -} \ No newline at end of file +} diff --git a/lib/view/components/search/search_results_body/search_card.dart b/lib/view/components/search/search_results_body/search_card.dart index e56b270..d4c8129 100644 --- a/lib/view/components/search/search_results_body/search_card.dart +++ b/lib/view/components/search/search_results_body/search_card.dart @@ -34,7 +34,7 @@ class SearchResultCard extends StatelessWidget { Row( children: [ WKBadge( - result.tags.firstWhere( + level: result.tags.firstWhere( (tag) => tag.contains('wanikani'), orElse: () => '', ), diff --git a/lib/view/screens/search/kanji_view.dart b/lib/view/screens/search/kanji_view.dart index 04a88d7..77f8042 100644 --- a/lib/view/screens/search/kanji_view.dart +++ b/lib/view/screens/search/kanji_view.dart @@ -8,6 +8,6 @@ class KanjiView extends StatelessWidget { @override Widget build(BuildContext context) { - return KanjiSearchBody(); + return const KanjiSearchBody(); } }