refactor: Enable more lints

This commit is contained in:
Christian Pauly 2021-04-14 10:37:15 +02:00
commit 0dc147b5c8
31 changed files with 103 additions and 98 deletions

View file

@ -300,13 +300,13 @@ class BackgroundPush {
}
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
var initializationSettingsAndroid =
final initializationSettingsAndroid =
AndroidInitializationSettings('notifications_icon');
var initializationSettingsIOS =
final initializationSettingsIOS =
IOSInitializationSettings(onDidReceiveLocalNotification: (i, a, b, c) {
return null;
});
var initializationSettings = InitializationSettings(
final initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsIOS,
);
@ -622,7 +622,7 @@ class BackgroundPush {
);
// Show notification
var androidPlatformChannelSpecifics = _getAndroidNotificationDetails(
final androidPlatformChannelSpecifics = _getAndroidNotificationDetails(
styleInformation: MessagingStyleInformation(
person,
conversationTitle: title,
@ -636,8 +636,8 @@ class BackgroundPush {
),
ticker: l10n.newMessageInFluffyChat,
);
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
final iOSPlatformChannelSpecifics = IOSNotificationDetails();
final platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics,
iOS: iOSPlatformChannelSpecifics,
);
@ -655,8 +655,8 @@ class BackgroundPush {
await setupLocalNotificationsPlugin();
await loadLocale();
String eventId = data['event_id'];
String roomId = data['room_id'];
final String eventId = data['event_id'];
final String roomId = data['room_id'];
final unread = ((data['counts'] is String
? json.decode(data.tryGet<String>('counts', '{}'))
: data.tryGet<Map<String, dynamic>>(
@ -668,9 +668,9 @@ class BackgroundPush {
}
// Display notification
var androidPlatformChannelSpecifics = _getAndroidNotificationDetails();
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
final androidPlatformChannelSpecifics = _getAndroidNotificationDetails();
final iOSPlatformChannelSpecifics = IOSNotificationDetails();
final platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics,
iOS: iOSPlatformChannelSpecifics,
);
@ -692,20 +692,20 @@ class BackgroundPush {
final thumbnail = width == null && height == null ? false : true;
final tempDirectory = (await getTemporaryDirectory()).path;
final prefix = thumbnail ? 'thumbnail' : '';
var file =
final file =
File('$tempDirectory/${prefix}_${content.toString().split("/").last}');
if (!file.existsSync()) {
final url = thumbnail
? content.getThumbnail(client, width: width, height: height)
: content.getDownloadLink(client);
var request = await HttpClient().getUrl(Uri.parse(url));
var response = await request.close();
final request = await HttpClient().getUrl(Uri.parse(url));
final response = await request.close();
if (response.statusCode >= 300) {
// we are not in the 2xx range
return null;
}
var bytes = await consolidateHttpClientResponseBytes(response);
final bytes = await consolidateHttpClientResponseBytes(response);
await file.writeAsBytes(bytes);
}

View file

@ -44,13 +44,13 @@ extension DateTimeExtension on DateTime {
/// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week
/// day if the ChatTime is this week and a date string else.
String localizedTimeShort(BuildContext context) {
var now = DateTime.now();
final now = DateTime.now();
var sameYear = now.year == year;
final sameYear = now.year == year;
var sameDay = sameYear && now.month == month && now.day == day;
final sameDay = sameYear && now.month == month && now.day == day;
var sameWeek = sameYear &&
final sameWeek = sameYear &&
!sameDay &&
now.millisecondsSinceEpoch - millisecondsSinceEpoch <
1000 * 60 * 60 * 24 * 7;
@ -86,11 +86,11 @@ extension DateTimeExtension on DateTime {
/// shows the date.
/// TODO: Add localization
String localizedTime(BuildContext context) {
var now = DateTime.now();
final now = DateTime.now();
var sameYear = now.year == year;
final sameYear = now.year == year;
var sameDay = sameYear && now.month == month && now.day == day;
final sameDay = sameYear && now.month == month && now.day == day;
if (sameDay) return localizedTimeOfDay(context);
return L10n.of(context).dateAndTimeOfDay(

View file

@ -15,7 +15,7 @@ extension MatrixFileExtension on MatrixFile {
if (kIsWeb) {
final fileName = name.split('/').last;
final mimeType = mime(fileName);
var element = html.document.createElement('a');
final element = html.document.createElement('a');
element.setAttribute(
'href', html.Url.createObjectUrlFromBlob(html.Blob([bytes])));
element.setAttribute('target', '_blank');

View file

@ -40,7 +40,7 @@ abstract class PlatformInfos {
}
static void showDialog(BuildContext context) async {
var version = await PlatformInfos.getVersion();
final version = await PlatformInfos.getVersion();
showAboutDialog(
context: context,
useRootNavigator: false,

View file

@ -35,7 +35,7 @@ extension RoomStatusExtension on Room {
String getLocalizedTypingText(BuildContext context) {
var typingText = '';
var typingUsers = this.typingUsers;
final typingUsers = this.typingUsers;
typingUsers.removeWhere((User u) => u.id == client.userID);
if (AppConfig.hideTypingUsernames) {

View file

@ -40,7 +40,7 @@ class UrlLauncher {
var roomId = room?.id;
// we make the servers a set and later on convert to a list, so that we can easily
// deduplicate servers added via alias lookup and query parameter
var servers = <String>{};
final servers = <String>{};
if (room == null && roomIdOrAlias.sigil == '#') {
// we were unable to find the room locally...so resolve it
final response = await showFutureLoadingDialog(