Skip to content

Commit 1451ec0

Browse files
committedSep 13, 2024
fix dart analyzer error
1 parent 9a83862 commit 1451ec0

23 files changed

+53
-76
lines changed
 

‎lib/bean/appbar/drag_to_move_bar.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import 'package:window_manager/window_manager.dart';
2222
/// {@end-tool}
2323
class DragToMoveArea extends StatelessWidget {
2424
const DragToMoveArea({
25-
Key? key,
25+
super.key,
2626
required this.child,
27-
}) : super(key: key);
27+
});
2828

2929
final Widget child;
3030

‎lib/bean/card/bangumi_card.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BangumiCardV extends StatelessWidget {
3434
onTap: () async {
3535
infoController.bangumiItem = bangumiItem;
3636
if (popularController.searchKeyword == '') {
37-
popularController.keyword = bangumiItem.nameCn == '' ? bangumiItem.name ?? '' : (bangumiItem.nameCn ?? '');
37+
popularController.keyword = bangumiItem.nameCn == '' ? bangumiItem.name : (bangumiItem.nameCn);
3838
} else {
3939
popularController.keyword = popularController.searchKeyword;
4040
}

‎lib/bean/card/bangumi_history_card.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class _BangumiHistoryCardVState extends State<BangumiHistoryCardV> {
133133
Text('上次看到: 第${widget.historyItem.lastWatchEpisode}话',
134134
style: style),
135135
Text(
136-
'排名: ${widget.historyItem.bangumiItem.rank ?? '0.0'}',
136+
'排名: ${widget.historyItem.bangumiItem.rank}',
137137
style: style),
138138
Text(
139139
widget.historyItem.bangumiItem.type == 2

‎lib/bean/settings/settings.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class SetSwitchItem extends StatefulWidget {
1818
this.defaultVal,
1919
this.callFn,
2020
this.needReboot,
21-
Key? key,
22-
}) : super(key: key);
21+
super.key,
22+
});
2323

2424
@override
2525
State<SetSwitchItem> createState() => _SetSwitchItemState();
@@ -85,7 +85,7 @@ class SelectDialog<T> extends StatefulWidget {
8585
required this.title});
8686

8787
@override
88-
_SelectDialogState<T> createState() => _SelectDialogState<T>();
88+
State<SelectDialog<T>> createState() => _SelectDialogState<T>();
8989
}
9090

9191
class _SelectDialogState<T> extends State<SelectDialog<T>> {

‎lib/bean/widget/text_display.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import 'package:flutter_modular/flutter_modular.dart';
33
import 'package:kazumi/pages/video/video_controller.dart';
44

55
class TextDisplayWidget extends StatefulWidget {
6+
const TextDisplayWidget({super.key});
7+
68
@override
7-
_TextDisplayWidgetState createState() => _TextDisplayWidgetState();
9+
State<TextDisplayWidget> createState() => _TextDisplayWidgetState();
810
}
911

1012
class _TextDisplayWidgetState extends State<TextDisplayWidget> {

‎lib/pages/about/about_module.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:kazumi/utils/utils.dart';
21
import 'package:flutter/material.dart';
32
import 'package:kazumi/request/api.dart';
43
import 'package:kazumi/pages/about/about_page.dart';

‎lib/pages/error/http_error.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class HttpError extends StatelessWidget {
2929
fn!();
3030
},
3131
style: ButtonStyle(
32-
backgroundColor: MaterialStateProperty.resolveWith((states) {
32+
backgroundColor: WidgetStateProperty.resolveWith((states) {
3333
return Theme.of(context).colorScheme.primary.withAlpha(20);
3434
}),
3535
),

‎lib/pages/favorite/favorite_controller.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flutter/material.dart';
21
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
32
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
43
import 'package:kazumi/utils/storage.dart';
@@ -10,7 +9,7 @@ import 'package:kazumi/utils/logger.dart';
109

1110
part 'favorite_controller.g.dart';
1211

13-
class FavoriteController = _FavoriteController with _$FavoriteController;
12+
class FavoriteController = _FavoriteController with _$FavoriteController;
1413

1514
abstract class _FavoriteController with Store {
1615
// late var storedFavorites = GStorage.favorites;

‎lib/pages/index_page.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import 'package:kazumi/utils/utils.dart';
22
import 'package:flutter/material.dart';
33
import 'package:kazumi/pages/menu/menu.dart';
44
import 'package:kazumi/pages/menu/side_menu.dart';
5-
import 'package:logger/logger.dart';
6-
import 'package:kazumi/utils/logger.dart';
75

86

97
class IndexPage extends StatefulWidget {
108
//const IndexPage({super.key});
11-
const IndexPage({Key? key}) : super(key: key);
9+
const IndexPage({super.key});
1210

1311
@override
1412
State<IndexPage> createState() => _IndexPageState();

‎lib/pages/info/info_controller.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flutter/foundation.dart';
21
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
32
import 'package:kazumi/plugins/plugins_controller.dart';
43
import 'package:kazumi/pages/video/video_controller.dart';

‎lib/pages/menu/side_menu.dart

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class SideNavigationBarState extends ChangeNotifier {
3434
}
3535

3636
class _SideMenu extends State<SideMenu> {
37-
final PageController _page = PageController();
38-
3937
@override
4038
Widget build(BuildContext context) {
4139
return ChangeNotifierProvider(

‎lib/pages/my/my_page.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class _MyPageState extends State<MyPage> {
4444
onBackPressed(context);
4545
},
4646
child: Scaffold(
47-
appBar: const SysAppBar(title: const Text('我的')),
47+
appBar: const SysAppBar(title: Text('我的')),
4848
body: Column(
4949
children: [
5050
ListTile(

‎lib/pages/player/player_item.dart

+3-5
Original file line numberDiff line numberDiff line change
@@ -1238,12 +1238,10 @@ class _PlayerItemState extends State<PlayerItem>
12381238
padding:
12391239
const EdgeInsets.only(left: 10.0),
12401240
child: Text(
1241-
Utils.durationToString(
1241+
"${Utils.durationToString(
12421242
playerController
1243-
.currentPosition) +
1244-
" / " +
1245-
Utils.durationToString(
1246-
playerController.duration),
1243+
.currentPosition)} / ${Utils.durationToString(
1244+
playerController.duration)}",
12471245
style: TextStyle(
12481246
color: Colors.white,
12491247
fontSize: !Utils.isCompact()

‎lib/pages/plugin_editor/plugin_shop_page.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class _PluginShopPageState extends State<PluginShopPage> {
102102
borderRadius: BorderRadius.circular(16.0),
103103
),
104104
child: Text(
105-
'${pluginsController.pluginHTTPList[index].version}',
105+
pluginsController.pluginHTTPList[index].version,
106106
style: TextStyle(
107107
color: Theme.of(context)
108108
.colorScheme

‎lib/pages/plugin_editor/plugin_view_page.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class _PluginViewPageState extends State<PluginViewPage> {
104104
pluginsController.loadPlugins();
105105
SmartDialog.dismiss();
106106
},
107-
child: Text('导入'),
107+
child: const Text('导入'),
108108
);
109109
})
110110
],
@@ -191,7 +191,7 @@ class _PluginViewPageState extends State<PluginViewPage> {
191191
Utils.jsonToKazumiBase64(json.encode(
192192
pluginsController.pluginList[index]
193193
.toJson())),
194-
style: TextStyle(
194+
style: const TextStyle(
195195
fontWeight: FontWeight.bold),
196196
textAlign: TextAlign.center,
197197
),

‎lib/pages/settings/displaymode_settings.dart

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import 'package:flutter/services.dart';
44
import 'package:flutter_displaymode/flutter_displaymode.dart';
55
import 'package:hive/hive.dart';
66
import 'package:kazumi/utils/storage.dart';
7-
import 'package:logger/logger.dart';
8-
import 'package:kazumi/utils/logger.dart';
97

108
class SetDiaplayMode extends StatefulWidget {
119
const SetDiaplayMode({super.key});

‎lib/pages/timeline/timeline_page.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class _TimelinePageState extends State<TimelinePage>
112112
}
113113

114114
Widget renderBody(Orientation orientation) {
115-
if (timelineController.bangumiCalendar.length > 0) {
115+
if (timelineController.bangumiCalendar.isNotEmpty) {
116116
return TabBarView(
117117
controller: controller,
118118
children: contentGrid(timelineController.bangumiCalendar, orientation),

‎lib/pages/video/video_page.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class _VideoPageState extends State<VideoPage>
258258
if (road.name == '播放列表${roadIndex + 1}') {
259259
int count = 1;
260260
for (var urlItem in road.data) {
261-
int _count = count;
261+
int count0 = count;
262262
cardList.add(Container(
263263
margin: const EdgeInsets.only(bottom: 10), // 改为bottom间距
264264
child: Material(
@@ -267,12 +267,12 @@ class _VideoPageState extends State<VideoPage>
267267
clipBehavior: Clip.hardEdge,
268268
child: InkWell(
269269
onTap: () async {
270-
if (_count == videoPageController.currentEspisode &&
270+
if (count0 == videoPageController.currentEspisode &&
271271
roadIndex == videoPageController.currentRoad) {
272272
return;
273273
}
274274
KazumiLogger().log(Level.info, '视频链接为 $urlItem');
275-
videoPageController.changeEpisode(_count,
275+
videoPageController.changeEpisode(count0,
276276
currentRoad: roadIndex);
277277
},
278278
child: Padding(
@@ -283,7 +283,7 @@ class _VideoPageState extends State<VideoPage>
283283
children: <Widget>[
284284
Row(
285285
children: [
286-
if (_count ==
286+
if (count0 ==
287287
(videoPageController
288288
.currentEspisode) &&
289289
roadIndex ==
@@ -301,7 +301,7 @@ class _VideoPageState extends State<VideoPage>
301301
'第$count话',
302302
style: TextStyle(
303303
fontSize: 13,
304-
color: (_count ==
304+
color: (count0 ==
305305
(videoPageController
306306
.currentEspisode) &&
307307
roadIndex ==

‎lib/pages/webview/webview_item_impel/webview_windows_item_impel.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class _WebviewWindowsItemImpelState extends State<WebviewWindowsItemImpel> {
2828

2929
@override
3030
void dispose() {
31-
_subscriptions.forEach((s) => s.cancel());
31+
for (var s in _subscriptions) {
32+
s.cancel();
33+
}
3234
webviewDesktopItemController.dispose();
3335
super.dispose();
3436
}

‎lib/plugins/plugins.dart

+21-21
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ class Plugin {
8585
}
8686

8787
Map<String, dynamic> toJson() {
88-
final Map<String, dynamic> data = new Map<String, dynamic>();
89-
data['api'] = this.api;
90-
data['type'] = this.type;
91-
data['name'] = this.name;
92-
data['version'] = this.version;
93-
data['muliSources'] = this.muliSources;
94-
data['useWebview'] = this.useWebview;
95-
data['useNativePlayer'] = this.useNativePlayer;
96-
data['usePost'] = this.usePost;
97-
data['userAgent'] = this.userAgent;
98-
data['baseURL'] = this.baseUrl;
99-
data['searchURL'] = this.searchURL;
100-
data['searchList'] = this.searchList;
101-
data['searchName'] = this.searchName;
102-
data['searchResult'] = this.searchResult;
103-
data['chapterRoads'] = this.chapterRoads;
104-
data['chapterResult'] = this.chapterResult;
88+
final Map<String, dynamic> data = <String, dynamic>{};
89+
data['api'] = api;
90+
data['type'] = type;
91+
data['name'] = name;
92+
data['version'] = version;
93+
data['muliSources'] = muliSources;
94+
data['useWebview'] = useWebview;
95+
data['useNativePlayer'] = useNativePlayer;
96+
data['usePost'] = usePost;
97+
data['userAgent'] = userAgent;
98+
data['baseURL'] = baseUrl;
99+
data['searchURL'] = searchURL;
100+
data['searchList'] = searchList;
101+
data['searchName'] = searchName;
102+
data['searchResult'] = searchResult;
103+
data['chapterRoads'] = chapterRoads;
104+
data['chapterResult'] = chapterResult;
105105
return data;
106106
}
107107

@@ -118,14 +118,14 @@ class Plugin {
118118
path: uri.path,
119119
);
120120
var httpHeaders = {
121-
'referer': baseUrl + '/',
121+
'referer': '$baseUrl/',
122122
'Content-Type': 'application/x-www-form-urlencoded',
123123
};
124124
resp = await Request().post(postUri.toString(),
125125
options: Options(headers: httpHeaders), data: queryParams, shouldRethrow: shouldRethrow);
126126
} else {
127127
var httpHeaders = {
128-
'referer': baseUrl + '/',
128+
'referer': '$baseUrl/',
129129
};
130130
resp =
131131
await Request().get(queryURL, options: Options(headers: httpHeaders), shouldRethrow: shouldRethrow);
@@ -163,7 +163,7 @@ class Plugin {
163163
queryURL = baseUrl + url;
164164
}
165165
var httpHeaders = {
166-
'referer': baseUrl + '/',
166+
'referer': '$baseUrl/',
167167
};
168168
try {
169169
var resp =
@@ -178,7 +178,7 @@ class Plugin {
178178
String itemUrl = item.node.attributes['href'] ?? '';
179179
chapterUrlList.add(itemUrl);
180180
});
181-
if (chapterUrlList.length != 0) {
181+
if (chapterUrlList.isNotEmpty) {
182182
Road road = Road(name: '播放列表$count', data: chapterUrlList);
183183
roadList.add(road);
184184
count++;

‎lib/request/damaku.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class DanmakuRequest {
5757
};
5858
// 这里猜测了弹弹Play的分集命名规则,例如上面的番剧ID为1758,第一集弹幕库ID大概率为17580001,但是此命名规则并没有体现在官方API文档里,保险的做法是请求 Api.dandanInfo
5959
KazumiLogger().log(Level.info,
60-
"弹幕请求最终URL ${Api.dandanAPI + "$bangumiID" + episode.toString().padLeft(4, '0')}");
60+
"弹幕请求最终URL ${"${Api.dandanAPI}$bangumiID${episode.toString().padLeft(4, '0')}"}");
6161
final res = await Request().get(
62-
(Api.dandanAPI + "$bangumiID" + episode.toString().padLeft(4, '0')),
62+
("${Api.dandanAPI}$bangumiID${episode.toString().padLeft(4, '0')}"),
6363
data: withRelated,
6464
options: Options(headers: httpHeaders));
6565

‎lib/utils/storage.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GStorage {
2424
final hiveBoxFile = File('${appDocumentDir.path}/hive/$boxName.hive');
2525
if (await hiveBoxFile.exists()) {
2626
await hiveBoxFile.copy(backupFilePath);
27-
print('Backup success: ${backupFilePath}');
27+
print('Backup success: $backupFilePath');
2828
} else {
2929
print('Hive box not exists');
3030
}

‎test/widget_test.dart

-16
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,10 @@
55
// gestures. You can also use WidgetTester to find child widgets in the widget
66
// tree, read text, and verify that the values of widget properties are correct.
77

8-
import 'package:flutter/material.dart';
98
import 'package:flutter_test/flutter_test.dart';
109

11-
import 'package:kazumi/main.dart';
1210

1311
void main() {
1412
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15-
// Build our app and trigger a frame.
16-
await tester.pumpWidget(const MyApp());
17-
18-
// Verify that our counter starts at 0.
19-
expect(find.text('0'), findsOneWidget);
20-
expect(find.text('1'), findsNothing);
21-
22-
// Tap the '+' icon and trigger a frame.
23-
await tester.tap(find.byIcon(Icons.add));
24-
await tester.pump();
25-
26-
// Verify that our counter has incremented.
27-
expect(find.text('0'), findsNothing);
28-
expect(find.text('1'), findsOneWidget);
2913
});
3014
}

0 commit comments

Comments
 (0)
Please sign in to comment.