refactor: Null safe dependencies

This commit is contained in:
Christian Pauly 2021-04-21 14:19:54 +02:00
commit 1a477adcb1
34 changed files with 320 additions and 381 deletions

View file

@ -34,7 +34,6 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_gen/gen_l10n/l10n_en.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:path_provider/path_provider.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'platform_infos.dart';
import '../config/app_config.dart';
import '../config/setting_keys.dart';
@ -130,12 +129,7 @@ class BackgroundPush {
bool useDeviceSpecificAppId = false,
}) async {
if (PlatformInfos.isIOS) {
FirebaseMessaging()
.requestNotificationPermissions(IosNotificationSettings(
sound: true,
alert: true,
badge: true,
));
await _fcmSharedIsolate.requestPermission();
}
final clientName = PlatformInfos.clientName;
oldTokens ??= <String>{};
@ -355,7 +349,8 @@ class BackgroundPush {
.toString()
.split('?')
.first;
final res = json.decode(utf8.decode((await http.get(url)).bodyBytes));
final res =
json.decode(utf8.decode((await http.get(Uri.parse(url))).bodyBytes));
if (res['gateway'] == 'matrix') {
endpoint = url;
}
@ -699,7 +694,7 @@ class BackgroundPush {
final url = thumbnail
? content.getThumbnail(client, width: width, height: height)
: content.getDownloadLink(client);
final request = await HttpClient().getUrl(Uri.parse(url));
final request = await HttpClient().getUrl(url);
final response = await request.close();
if (response.statusCode >= 300) {
// we are not in the 2xx range

View file

@ -8,7 +8,7 @@ Future<Database> constructDb(
String password = ''}) async {
Logs().v('[Moor] Using moor web');
return Database(WebDatabase.withStorage(
MoorWebStorage.indexedDbIfSupported(filename),
await MoorWebStorage.indexedDbIfSupported(filename),
logStatements: logStatements));
}

View file

@ -87,7 +87,7 @@ extension LocalizedBody on Event {
}
// check if the url is cached
final url = Uri.parse(mxcUrl).getDownloadLink(room.client);
final file = await DefaultCacheManager().getFileFromCache(url);
final file = await DefaultCacheManager().getFileFromCache(url.toString());
return file != null;
}
@ -96,8 +96,8 @@ extension LocalizedBody on Event {
final mxcUrl = attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail);
_downloadAndDecryptFutures[mxcUrl] ??= downloadAndDecryptAttachment(
getThumbnail: getThumbnail,
downloadCallback: (String url) async {
final file = await DefaultCacheManager().getSingleFile(url);
downloadCallback: (Uri url) async {
final file = await DefaultCacheManager().getSingleFile(url.toString());
return await file.readAsBytes();
},
);

View file

@ -7,7 +7,7 @@ extension FilteredTimelineExtension on Timeline {
final filteredEvents = events
.where((e) =>
// always filter out edit and reaction relationships
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
!{RelationshipTypes.edit, RelationshipTypes.reaction}
.contains(e.relationshipType) &&
// always filter out m.key.* events
!e.type.startsWith('m.key.verification.') &&

View file

@ -6,7 +6,7 @@ import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:universal_html/html.dart' as html;
import 'package:mime_type/mime_type.dart';
import 'package:permission_handler/permission_handler.dart';

View file

@ -22,13 +22,13 @@ abstract class SentryController {
return await storage.getItemBool(SettingKeys.sentry);
}
static final sentry = SentryClient(dsn: AppConfig.sentryDns);
static final sentry = SentryClient(SentryOptions(dsn: AppConfig.sentryDns));
static void captureException(error, stackTrace) async {
Logs().e('Capture exception', error, stackTrace);
if (!kDebugMode && await getSentryStatus()) {
await sentry.captureException(
exception: error,
error,
stackTrace: stackTrace,
);
}