Fix some more code style
This commit is contained in:
parent
fe5c5a4cce
commit
cfe5a65380
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:sembast/sembast.dart';
|
||||
import 'package:sembast/timestamp.dart';
|
||||
|
||||
import './kanji_query.dart';
|
||||
import './word_query.dart';
|
||||
|
|
|
@ -50,7 +50,9 @@ class ColorSet {
|
|||
MaterialColor createMaterialColor(Color color) {
|
||||
final List<double> strengths = [.05];
|
||||
final swatch = <int, Color>{};
|
||||
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);
|
||||
|
|
|
@ -12,13 +12,13 @@ Route<dynamic> 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),
|
||||
);
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<KanjiSearchBar> {
|
||||
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<KanjiSearchBar> {
|
|||
}
|
||||
|
||||
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<KanjiSearchBar> {
|
|||
return TextField(
|
||||
controller: textController,
|
||||
onChanged: (text) {
|
||||
if (onChanged != null) onChanged!(text);
|
||||
if (widget.onChanged != null) widget.onChanged!(text);
|
||||
},
|
||||
onSubmitted: (_) => {},
|
||||
decoration: InputDecoration(
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ class SearchResultCard extends StatelessWidget {
|
|||
Row(
|
||||
children: [
|
||||
WKBadge(
|
||||
result.tags.firstWhere(
|
||||
level: result.tags.firstWhere(
|
||||
(tag) => tag.contains('wanikani'),
|
||||
orElse: () => '',
|
||||
),
|
||||
|
|
|
@ -8,6 +8,6 @@ class KanjiView extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return KanjiSearchBody();
|
||||
return const KanjiSearchBody();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue