fix: remove unused null check

This commit is contained in:
xijieyin 2022-06-03 22:38:13 +08:00
parent 731d50935b
commit e97a493135
13 changed files with 144 additions and 144 deletions

View File

@ -525,7 +525,7 @@ class __HistoryState extends State<_History> {
onPressed: () async {
audio.delFromPlaylist(episode!);
Fluttertoast.showToast(
msg: s!.toastRemovePlaylist,
msg: s.toastRemovePlaylist,
gravity: ToastGravity.BOTTOM,
);
})
@ -534,7 +534,7 @@ class __HistoryState extends State<_History> {
onPressed: () async {
audio.addToPlaylist(episode!);
Fluttertoast.showToast(
msg: s!.toastAddPlaylist,
msg: s.toastAddPlaylist,
gravity: ToastGravity.BOTTOM,
);
});
@ -724,7 +724,7 @@ class __PlaylistsState extends State<_Playlists> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
s!.queue,
s.queue,
style: context.textTheme.headline6,
),
Text(
@ -743,14 +743,13 @@ class __PlaylistsState extends State<_Playlists> {
children: <Widget>[
Text(s.play.toUpperCase(),
style: TextStyle(
color:
Theme.of(context).accentColor,
color: context.accentColor,
fontSize: 15,
fontWeight: FontWeight.bold,
)),
Icon(
Icons.play_arrow,
color: Theme.of(context).accentColor,
color: context.accentColor,
),
],
),
@ -798,7 +797,7 @@ class __PlaylistsState extends State<_Playlists> {
),
title: Text(data[index].name!),
subtitle: Text(
'${data[index].length} ${s!.episode(data[index].length).toLowerCase()}'),
'${data[index].length} ${s.episode(data[index].length).toLowerCase()}'),
trailing: TextButton(
style: TextButton.styleFrom(
primary: context.accentColor,
@ -808,13 +807,13 @@ class __PlaylistsState extends State<_Playlists> {
children: <Widget>[
Text(s.play.toUpperCase(),
style: TextStyle(
color: Theme.of(context).accentColor,
color: context.accentColor,
fontSize: 15,
fontWeight: FontWeight.bold,
)),
Icon(
Icons.play_arrow,
color: Theme.of(context).accentColor,
color: context.accentColor,
),
],
),

View File

@ -43,9 +43,9 @@ class _PlaylistDetailState extends State<PlaylistDetail> {
),
title: Text(_selectedEpisodes.isEmpty
? widget.playlist.isQueue
? s!.queue
? s.queue
: widget.playlist.name!
: s!.selected(_selectedEpisodes.length)),
: s.selected(_selectedEpisodes.length)),
actions: [
if (_selectedEpisodes.isNotEmpty)
IconButton(
@ -86,40 +86,40 @@ class _PlaylistDetailState extends State<PlaylistDetail> {
],
),
body: Selector<AudioPlayerNotifier, List<Playlist>>(
selector: (_, audio) => audio.playlists,
builder: (_, data, __) {
final playlist = data.firstWhereOrNull(
(e) => e == widget.playlist,
);
final episodes = playlist?.episodes ?? [];
return ReorderableListView(
onReorder: (oldIndex, newIndex) {
if (widget.playlist.isQueue) {
context
.read<AudioPlayerNotifier>()
.reorderPlaylist(oldIndex, newIndex);
setState(() {});
} else {
context
.read<AudioPlayerNotifier>()
.reorderEpisodesInPlaylist(widget.playlist,
oldIndex: oldIndex, newIndex: newIndex);
setState(() {});
}
},
scrollDirection: Axis.vertical,
children: episodes.map<Widget>((episode) {
return _PlaylistItem(episode,
key: ValueKey(episode!.enclosureUrl),
onSelect: (episode) {
_selectedEpisodes.add(episode);
setState(() {});
}, onRemove: (episode) {
_selectedEpisodes.remove(episode);
setState(() {});
}, reset: _resetSelected);
}).toList());
}),
selector: (_, audio) => audio.playlists,
builder: (_, data, __) {
final playlist = data.firstWhereOrNull(
(e) => e == widget.playlist,
);
final episodes = playlist?.episodes ?? [];
return ReorderableListView(
onReorder: (oldIndex, newIndex) {
if (widget.playlist.isQueue) {
context
.read<AudioPlayerNotifier>()
.reorderPlaylist(oldIndex, newIndex);
setState(() {});
} else {
context.read<AudioPlayerNotifier>().reorderEpisodesInPlaylist(
widget.playlist,
oldIndex: oldIndex,
newIndex: newIndex);
setState(() {});
}
},
scrollDirection: Axis.vertical,
children: episodes.map<Widget>((episode) {
return _PlaylistItem(episode,
key: ValueKey(episode!.enclosureUrl), onSelect: (episode) {
_selectedEpisodes.add(episode);
setState(() {});
}, onRemove: (episode) {
_selectedEpisodes.remove(episode);
setState(() {});
}, reset: _resetSelected);
}).toList());
},
),
);
}
}
@ -269,7 +269,7 @@ class __PlaylistItemState extends State<_PlaylistItem>
_episodeTag(
episode.duration == 0
? ''
: s!.minsCount(episode.duration! ~/ 60),
: s.minsCount(episode.duration! ~/ 60),
Colors.cyan[300]),
if (episode.enclosureLength != null)
_episodeTag(
@ -338,7 +338,7 @@ class __PlaylistSettingState extends State<_PlaylistSetting> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
FlatButton(
TextButton(
onPressed: () => setState(() {
_clearConfirm = false;
}),
@ -381,7 +381,7 @@ class __PlaylistSettingState extends State<_PlaylistSetting> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
FlatButton(
TextButton(
onPressed: () => setState(() {
_removeConfirm = false;
}),
@ -407,9 +407,9 @@ class __PlaylistSettingState extends State<_PlaylistSetting> {
child: Row(
children: [
Icon(Icons.info_outline,
size: 16, color: context.textColor!.withAlpha(90)),
size: 16, color: context.textColor.withAlpha(90)),
Text(s.defaultQueueReminder,
style: TextStyle(color: context.textColor!.withAlpha(90))),
style: TextStyle(color: context.textColor.withAlpha(90))),
],
),
)

View File

@ -56,7 +56,7 @@ class _CustomTabsState extends State<CustomTabView>
_currentPosition = widget.itemCount - 1;
_currentPosition = _currentPosition! < 0 ? 0 : _currentPosition;
if (widget.onPositionChange is ValueChanged<int>) {
WidgetsBinding.instance!.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
widget.onPositionChange!(_currentPosition);
}

View File

@ -457,14 +457,16 @@ class _PodcastDetailState extends State<PodcastDetail> {
borderRadius: BorderRadius.circular(5),
border: Border.all(
width: 2,
color: context.textColor!.withOpacity(0.2))),
color: context.textColor.withOpacity(0.2))),
child: _query == ''
? Row(
children: [
Text(s.search,
style: TextStyle(
color: context.textColor!
.withOpacity(0.4))),
Text(
s.search,
style: TextStyle(
color: context.textColor.withOpacity(0.4),
),
),
Spacer()
],
)
@ -732,7 +734,6 @@ class _PodcastDetailState extends State<PodcastDetail> {
physics: const AlwaysScrollableScrollPhysics(),
slivers: <Widget>[
SliverAppBar(
brightness: Brightness.dark,
actions: <Widget>[
IconButton(
icon: Icon(Icons.more_vert),

View File

@ -1,7 +1,6 @@
import 'dart:math' as math;
import 'package:feature_discovery/feature_discovery.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -65,7 +64,7 @@ class _PodcastManageState extends State<PodcastManage>
_controller.stop();
}
});
WidgetsBinding.instance!.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) {
FeatureDiscovery.discoverFeatures(context,
const <String>{addGroupFeature, configureGroup, configurePodcast});
});
@ -91,7 +90,7 @@ class _PodcastManageState extends State<PodcastManage>
context,
featureId: configureGroup,
tapTarget: Icon(Icons.menu),
title: s!.featureDiscoveryEditGroup,
title: s.featureDiscoveryEditGroup,
backgroundColor: Colors.cyan[600],
description: s.featureDiscoveryEditGroupDes,
buttonColor: Colors.cyan[500],
@ -126,9 +125,7 @@ class _PodcastManageState extends State<PodcastManage>
width: 50,
height: 50,
decoration: BoxDecoration(
color: _fraction! > 0.5
? Colors.red
: Theme.of(context).accentColor,
color: _fraction! > 0.5 ? Colors.red : context.accentColor,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
@ -159,10 +156,9 @@ class _PodcastManageState extends State<PodcastManage>
final s = context.s;
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
systemNavigationBarColor: Theme.of(context).primaryColor,
systemNavigationBarIconBrightness:
Theme.of(context).accentColorBrightness,
statusBarIconBrightness: context.brightness,
systemNavigationBarColor: context.primaryColor,
systemNavigationBarIconBrightness: context.iconBrightness,
// statusBarColor: Theme.of(context).primaryColor,
),
child: Scaffold(
@ -530,8 +526,8 @@ class _AddGroupState extends State<AddGroup> {
Navigator.of(context).pop();
}
},
child: Text(s.confirm,
style: TextStyle(color: Theme.of(context).accentColor)),
child:
Text(s.confirm, style: TextStyle(color: context.accentColor)),
)
],
title: SizedBox(width: context.width - 160, child: Text(s.newGroup)),

View File

@ -121,7 +121,7 @@ class _DataBackupState extends State<DataBackup> {
return;
}
Fluttertoast.showToast(
msg: s!.toastReadFile,
msg: s.toastReadFile,
gravity: ToastGravity.BOTTOM,
);
final filePath = filePickResult.files.first.path!;

View File

@ -84,9 +84,9 @@ class _DownloadsManageState extends State<DownloadsManage> {
var date = DateTime.fromMillisecondsSinceEpoch(downloadDate);
var diffrence = DateTime.now().toUtc().difference(date);
if (diffrence.inHours < 24) {
return s!.hoursAgo(diffrence.inHours);
return s.hoursAgo(diffrence.inHours);
} else if (diffrence.inDays < 7) {
return s!.daysAgo(diffrence.inDays);
return s.daysAgo(diffrence.inDays);
} else {
return DateFormat.yMMMd().format(
DateTime.fromMillisecondsSinceEpoch(pubDate!, isUtc: true).toLocal());

View File

@ -123,10 +123,9 @@ class _PlayedHistoryState extends State<PlayedHistory>
final s = context.s;
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
statusBarIconBrightness: context.brightness,
systemNavigationBarColor: Theme.of(context).primaryColor,
systemNavigationBarIconBrightness:
Theme.of(context).accentColorBrightness,
systemNavigationBarIconBrightness: context.iconBrightness,
),
child: Scaffold(
backgroundColor: context.primaryColor,
@ -147,7 +146,7 @@ class _PlayedHistoryState extends State<PlayedHistory>
return FlexibleSpaceBar(
title: top < 70 + MediaQuery.of(context).padding.top
? Text(
s!.settingsHistory,
s.settingsHistory,
)
: Center(),
background: Padding(
@ -237,7 +236,7 @@ class _PlayedHistoryState extends State<PlayedHistory>
.data![index]
.playdate!),
style: TextStyle(
color: context.textColor!
color: context.textColor
.withOpacity(0.8),
fontSize: 15,
fontStyle:
@ -285,7 +284,7 @@ class _PlayedHistoryState extends State<PlayedHistory>
padding: EdgeInsets.all(2),
child: Text(
seconds == 0 && seekValue == 1
? s!.mark
? s.mark
: seconds!.toInt().toTime,
style: TextStyle(
color: Colors.white),
@ -334,7 +333,7 @@ class _PlayedHistoryState extends State<PlayedHistory>
DateFormat.yMd().add_jm().format(
snapshot.data![index].subDate),
style: TextStyle(
color: context.textColor!
color: context.textColor
.withOpacity(0.8),
fontSize: 15,
fontStyle: FontStyle.italic),
@ -348,7 +347,7 @@ class _PlayedHistoryState extends State<PlayedHistory>
snapshot.data![index].subDate)
.inDays))
: Text(
s!.removedAt(DateFormat.yMd()
s.removedAt(DateFormat.yMd()
.add_jm()
.format(snapshot
.data![index].delDate)),

View File

@ -65,11 +65,11 @@ class _LayoutSettingState extends State<LayoutSetting> {
final s = context.s;
switch (mode) {
case PlayerHeight.short:
return s!.playerHeightShort;
return s.playerHeightShort;
case PlayerHeight.mid:
return s!.playerHeightMed;
return s.playerHeightMed;
case PlayerHeight.tall:
return s!.playerHeightTall;
return s.playerHeightTall;
default:
return '';
}

View File

@ -1,5 +1,3 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -43,11 +41,11 @@ class _PlaySettingState extends State<PlaySetting> {
String _volumeEffect(BuildContext context, int? i) {
final s = context.s;
if (i == 2000) {
return s!.playerHeightShort;
return s.playerHeightShort;
} else if (i == 3000) {
return s!.playerHeightMed;
return s.playerHeightMed;
}
return s!.playerHeightTall;
return s.playerHeightTall;
}
Future<bool> _getMarkListenedSkip() async {
@ -142,7 +140,7 @@ class _PlaySettingState extends State<PlaySetting> {
var startTime = data.item1!;
final timeOfDay = await showCustomTimePicker(
context: context,
cancelText: s!.cancel,
cancelText: s.cancel,
confirmText: s.confirm,
helpText: '',
initialTime: TimeOfDay(
@ -227,10 +225,9 @@ class _PlaySettingState extends State<PlaySetting> {
final s = context.s;
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
systemNavigationBarColor: Theme.of(context).primaryColor,
systemNavigationBarIconBrightness:
Theme.of(context).accentColorBrightness,
statusBarIconBrightness: context.brightness,
systemNavigationBarColor: context.primaryColor,
systemNavigationBarIconBrightness: context.iconBrightness,
),
child: Scaffold(
appBar: AppBar(
@ -264,11 +261,13 @@ class _PlaySettingState extends State<PlaySetting> {
height: 30.0,
padding: EdgeInsets.symmetric(horizontal: 70),
alignment: Alignment.centerLeft,
child: Text(s.homeMenuPlaylist,
style: Theme.of(context)
.textTheme
.bodyText1!
.copyWith(color: Theme.of(context).accentColor)),
child: Text(
s.homeMenuPlaylist,
style: Theme.of(context)
.textTheme
.bodyText1!
.copyWith(color: context.accentColor),
),
),
Selector<SettingState, bool?>(
selector: (_, settings) => settings.autoPlay,
@ -389,9 +388,11 @@ class _PlaySettingState extends State<PlaySetting> {
height: 30.0,
padding: EdgeInsets.symmetric(horizontal: 70),
alignment: Alignment.centerLeft,
child: Text(s.sleepTimer,
style: context.textTheme.bodyText1!
.copyWith(color: Theme.of(context).accentColor)),
child: Text(
s.sleepTimer,
style: context.textTheme.bodyText1!
.copyWith(color: context.accentColor),
),
),
ListView(
physics: const BouncingScrollPhysics(),
@ -494,7 +495,7 @@ class __NotificationLayoutState extends State<_NotificationLayout> {
SizedBox(height: 8),
Text(des,
style: TextStyle(
fontSize: 12, color: context.textColor!.withOpacity(0.5)),
fontSize: 12, color: context.textColor.withOpacity(0.5)),
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.clip),
@ -526,8 +527,8 @@ class __NotificationLayoutState extends State<_NotificationLayout> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_notificationIcon(Icon(Icons.pause_circle_filled),
'${s!.play}| ${s.pause}'),
_notificationIcon(
Icon(Icons.pause_circle_filled), '${s.play}| ${s.pause}'),
_notificationIcon(Icon(Icons.fast_forward), s.fastForward),
_notificationIcon(Icon(Icons.skip_next), s.skipToNext),
_notificationIcon(Icon(Icons.close), s.stop),
@ -539,7 +540,7 @@ class __NotificationLayoutState extends State<_NotificationLayout> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_notificationIcon(Icon(Icons.pause_circle_filled),
'${s!.play}| ${s.pause}'),
'${s.play}| ${s.pause}'),
_notificationIcon(
Icon(Icons.fast_rewind), s.fastRewind),
_notificationIcon(Icon(Icons.skip_next), s.skipToNext),
@ -549,7 +550,7 @@ class __NotificationLayoutState extends State<_NotificationLayout> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_notificationIcon(Icon(Icons.fast_rewind), s!.fastRewind),
_notificationIcon(Icon(Icons.fast_rewind), s.fastRewind),
_notificationIcon(Icon(Icons.pause_circle_filled),
'${s.play}| ${s.pause}'),
_notificationIcon(
@ -612,38 +613,42 @@ class __SpeedListState extends State<_SpeedList> {
children: [
Text(s.settingsSpeedsDes),
FutureBuilder<List<double>>(
future: _getSpeedList(),
initialData: [],
builder: (context, snapshot) {
var speedSelected = snapshot.data;
return Wrap(
children: kSpeedToSelect
.map((e) => Padding(
padding: const EdgeInsets.only(right: 8.0),
child: FilterChip(
key: ValueKey<String>(e.toString()),
label: Text('X ${e.toStringAsFixed(1)}'),
selectedColor: context.accentColor,
labelStyle: TextStyle(
color: snapshot.data!.contains(e)
? Colors.white
: context.textColor),
elevation: 0,
showCheckmark: false,
selected: snapshot.data!.contains(e),
onSelected: (value) async {
if (!value) {
speedSelected!.remove(e);
} else {
speedSelected!.add(e);
}
await _saveSpeedList(speedSelected);
setState(() {});
},
),
))
.toList());
}),
future: _getSpeedList(),
initialData: [],
builder: (context, snapshot) {
var speedSelected = snapshot.data;
return Wrap(
children: kSpeedToSelect
.map(
(e) => Padding(
padding: const EdgeInsets.only(right: 8.0),
child: FilterChip(
key: ValueKey<String>(e.toString()),
label: Text('X ${e.toStringAsFixed(1)}'),
selectedColor: context.accentColor,
labelStyle: TextStyle(
color: snapshot.data!.contains(e)
? Colors.white
: context.textColor),
elevation: 0,
showCheckmark: false,
selected: snapshot.data!.contains(e),
onSelected: (value) async {
if (!value) {
speedSelected!.remove(e);
} else {
speedSelected!.add(e);
}
await _saveSpeedList(speedSelected);
setState(() {});
},
),
),
)
.toList(),
);
},
),
],
),
);

View File

@ -9,7 +9,7 @@ part of 'search_top_podcast.dart';
SearchTopPodcast<T> _$SearchTopPodcastFromJson<T>(Map<String, dynamic> json) {
return SearchTopPodcast<T>(
podcasts:
(json['podcasts'] as List?)?.map(_ConvertT<T>().fromJson)?.toList(),
(json['podcasts'] as List?)?.map(_ConvertT<T>().fromJson).toList(),
id: json['id'] as int?,
total: json['total'] as int?,
hasNext: json['has_next'] as bool?,
@ -20,7 +20,7 @@ SearchTopPodcast<T> _$SearchTopPodcastFromJson<T>(Map<String, dynamic> json) {
Map<String, dynamic> _$SearchTopPodcastToJson<T>(
SearchTopPodcast<T> instance) =>
<String, dynamic>{
'podcasts': instance.podcasts?.map(_ConvertT<T>().toJson)?.toList(),
'podcasts': instance.podcasts?.map(_ConvertT<T>().toJson).toList(),
'id': instance.id,
'page': instance.page,
'total': instance.total,

View File

@ -9,14 +9,14 @@ part of 'searchepisodes.dart';
SearchEpisodes<E> _$SearchEpisodesFromJson<E>(Map<String, dynamic> json) {
return SearchEpisodes<E>(
episodes:
(json['episodes'] as List?)?.map(_ConvertE<E>().fromJson)?.toList(),
(json['episodes'] as List?)?.map(_ConvertE<E>().fromJson).toList(),
nextEpisodeDate: json['next_episode_pub_date'] as int?,
);
}
Map<String, dynamic> _$SearchEpisodesToJson<E>(SearchEpisodes<E> instance) =>
<String, dynamic>{
'episodes': instance.episodes?.map(_ConvertE<E>().toJson)?.toList(),
'episodes': instance.episodes?.map(_ConvertE<E>().toJson).toList(),
'next_episode_pub_date': instance.nextEpisodeDate,
};

View File

@ -8,7 +8,7 @@ part of 'searchpodcast.dart';
SearchPodcast<P> _$SearchPodcastFromJson<P>(Map<String, dynamic> json) {
return SearchPodcast<P>(
results: (json['results'] as List?)?.map(_ConvertP<P>().fromJson)?.toList(),
results: (json['results'] as List?)?.map(_ConvertP<P>().fromJson).toList(),
nextOffset: json['next_offset'] as int?,
total: json['total'] as int?,
count: json['count'] as int?,
@ -17,7 +17,7 @@ SearchPodcast<P> _$SearchPodcastFromJson<P>(Map<String, dynamic> json) {
Map<String, dynamic> _$SearchPodcastToJson<P>(SearchPodcast<P> instance) =>
<String, dynamic>{
'results': instance.results?.map(_ConvertP<P>().toJson)?.toList(),
'results': instance.results?.map(_ConvertP<P>().toJson).toList(),
'next_offset': instance.nextOffset,
'total': instance.total,
'count': instance.count,