refactor: Enable more lints
This commit is contained in:
parent
b73030380e
commit
0dc147b5c8
31 changed files with 103 additions and 98 deletions
|
|
@ -27,10 +27,10 @@ class AudioPlayer extends StatefulWidget {
|
|||
_AudioPlayerState createState() => _AudioPlayerState();
|
||||
}
|
||||
|
||||
enum AudioPlayerStatus { NOT_DOWNLOADED, DOWNLOADING, DOWNLOADED }
|
||||
enum AudioPlayerStatus { notDownloaded, downloading, downloaded }
|
||||
|
||||
class _AudioPlayerState extends State<AudioPlayer> {
|
||||
AudioPlayerStatus status = AudioPlayerStatus.NOT_DOWNLOADED;
|
||||
AudioPlayerStatus status = AudioPlayerStatus.notDownloaded;
|
||||
|
||||
final FlutterSoundPlayer flutterSound = FlutterSoundPlayer();
|
||||
|
||||
|
|
@ -70,14 +70,14 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
|||
}
|
||||
|
||||
Future<void> _downloadAction() async {
|
||||
if (status != AudioPlayerStatus.NOT_DOWNLOADED) return;
|
||||
setState(() => status = AudioPlayerStatus.DOWNLOADING);
|
||||
if (status != AudioPlayerStatus.notDownloaded) return;
|
||||
setState(() => status = AudioPlayerStatus.downloading);
|
||||
try {
|
||||
final matrixFile =
|
||||
await widget.event.downloadAndDecryptAttachmentCached();
|
||||
setState(() {
|
||||
audioFile = matrixFile.bytes;
|
||||
status = AudioPlayerStatus.DOWNLOADED;
|
||||
status = AudioPlayerStatus.downloaded;
|
||||
});
|
||||
_playAction();
|
||||
} catch (e, s) {
|
||||
|
|
@ -126,7 +126,7 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
|||
});
|
||||
AudioPlayer.currentId = null;
|
||||
} else if (e != null) {
|
||||
var txt =
|
||||
final txt =
|
||||
'${e.position.inMinutes.toString().padLeft(2, '0')}:${(e.position.inSeconds % 60).toString().padLeft(2, '0')}';
|
||||
setState(() {
|
||||
maxPosition = e.duration.inMilliseconds.toDouble();
|
||||
|
|
@ -158,7 +158,7 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
|||
children: <Widget>[
|
||||
Container(
|
||||
width: 30,
|
||||
child: status == AudioPlayerStatus.DOWNLOADING
|
||||
child: status == AudioPlayerStatus.downloading
|
||||
? CircularProgressIndicator(strokeWidth: 2)
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
|
|
@ -171,7 +171,7 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
|||
? L10n.of(context).audioPlayerPause
|
||||
: L10n.of(context).audioPlayerPlay,
|
||||
onPressed: () {
|
||||
if (status == AudioPlayerStatus.DOWNLOADED) {
|
||||
if (status == AudioPlayerStatus.downloaded) {
|
||||
_playAction();
|
||||
} else {
|
||||
_downloadAction();
|
||||
|
|
@ -184,7 +184,7 @@ class _AudioPlayerState extends State<AudioPlayer> {
|
|||
value: currentPosition,
|
||||
onChanged: (double position) => flutterSound
|
||||
.seekToPlayer(Duration(milliseconds: position.toInt())),
|
||||
max: status == AudioPlayerStatus.DOWNLOADED ? maxPosition : 0,
|
||||
max: status == AudioPlayerStatus.downloaded ? maxPosition : 0,
|
||||
min: 0,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Avatar extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var thumbnail = mxContent?.getThumbnail(
|
||||
final thumbnail = mxContent?.getThumbnail(
|
||||
client ?? Matrix.of(context).client,
|
||||
width: size * MediaQuery.of(context).devicePixelRatio,
|
||||
height: size * MediaQuery.of(context).devicePixelRatio,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
.listen(
|
||||
(u) => setState(() => null),
|
||||
);
|
||||
var items = <PopupMenuEntry<String>>[
|
||||
final items = <PopupMenuEntry<String>>[
|
||||
widget.room.pushRuleState == PushRuleState.notify
|
||||
? PopupMenuItem<String>(
|
||||
value: 'mute',
|
||||
|
|
@ -66,7 +66,7 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
case 'leave':
|
||||
var confirmed = await showOkCancelAlertDialog(
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
title: L10n.of(context).areYouSure,
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
));
|
||||
break;
|
||||
case KeyVerificationState.waitingSas:
|
||||
var acceptText = widget.request.sasTypes.contains('emoji')
|
||||
final acceptText = widget.request.sasTypes.contains('emoji')
|
||||
? L10n.of(context).waitingPartnerEmoji
|
||||
: L10n.of(context).waitingPartnerNumbers;
|
||||
body = Column(
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||
_recordedPath = '${tempDir.path}/recording${ext[codec.index]}';
|
||||
|
||||
// delete any existing file
|
||||
var outputFile = File(_recordedPath);
|
||||
final outputFile = File(_recordedPath);
|
||||
if (outputFile.existsSync()) {
|
||||
await outputFile.delete();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ class Message extends StatelessWidget {
|
|||
return StateMessage(event, unfold: unfold);
|
||||
}
|
||||
|
||||
var client = Matrix.of(context).client;
|
||||
final client = Matrix.of(context).client;
|
||||
final ownMessage = event.senderId == client.userID;
|
||||
var alignment = ownMessage ? Alignment.topRight : Alignment.topLeft;
|
||||
final alignment = ownMessage ? Alignment.topRight : Alignment.topLeft;
|
||||
var color = Theme.of(context).secondaryHeaderColor;
|
||||
final sameSender = nextEvent != null &&
|
||||
[EventTypes.Message, EventTypes.Sticker].contains(nextEvent.type)
|
||||
|
|
@ -58,7 +58,7 @@ class Message extends StatelessWidget {
|
|||
: Theme.of(context).brightness == Brightness.dark
|
||||
? Colors.white
|
||||
: Colors.black;
|
||||
var rowMainAxisAlignment =
|
||||
final rowMainAxisAlignment =
|
||||
ownMessage ? MainAxisAlignment.end : MainAxisAlignment.start;
|
||||
|
||||
final displayEvent = event.getDisplayEvent(timeline);
|
||||
|
|
@ -72,7 +72,7 @@ class Message extends StatelessWidget {
|
|||
: Theme.of(context).primaryColor;
|
||||
}
|
||||
|
||||
var rowChildren = <Widget>[
|
||||
final rowChildren = <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: alignment,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ParticipantListItem extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var membershipBatch = <Membership, String>{
|
||||
final membershipBatch = <Membership, String>{
|
||||
Membership.join: '',
|
||||
Membership.ban: L10n.of(context).banned,
|
||||
Membership.invite: L10n.of(context).invited,
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
|
||||
Future<void> initConfig() async {
|
||||
try {
|
||||
var configJsonString =
|
||||
final configJsonString =
|
||||
utf8.decode((await http.get('config.json')).bodyBytes);
|
||||
final configJson = json.decode(configJsonString);
|
||||
AppConfig.loadFromJson(configJson);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class UserBottomSheet extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final client = user.room.client;
|
||||
final presence = client.presences[user.id];
|
||||
var items = <PopupMenuEntry<String>>[];
|
||||
final items = <PopupMenuEntry<String>>[];
|
||||
|
||||
if (onMention != null) {
|
||||
items.add(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue