refactor: Null safe dependencies

This commit is contained in:
Christian Pauly 2021-04-11 09:49:24 +02:00
parent 76199418b2
commit f58de43223
27 changed files with 283 additions and 308 deletions

View File

@ -15,7 +15,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
import 'package:url_launcher/url_launcher.dart';
import '../utils/localized_exception_extension.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:universal_html/html.dart' as html;
class HomeserverPicker extends StatefulWidget {
@override

View File

@ -14,7 +14,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_app_lock/flutter_app_lock.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:universal_html/html.dart' as html;
import 'views/widgets/matrix.dart';
import 'config/themes.dart';

View File

@ -130,12 +130,11 @@ class BackgroundPush {
bool useDeviceSpecificAppId = false,
}) async {
if (PlatformInfos.isIOS) {
FirebaseMessaging()
.requestNotificationPermissions(IosNotificationSettings(
await FirebaseMessaging.instance.requestPermission(
sound: true,
alert: true,
badge: true,
));
);
}
final clientName = PlatformInfos.clientName;
oldTokens ??= <String>{};
@ -355,7 +354,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 +699,7 @@ class BackgroundPush {
final url = thumbnail
? content.getThumbnail(client, width: width, height: height)
: content.getDownloadLink(client);
var request = await HttpClient().getUrl(Uri.parse(url));
var request = await HttpClient().getUrl(url);
var 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

@ -5,7 +5,7 @@ import 'dart:ui';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
import 'package:emoji_picker/emoji_picker.dart';
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:fluffychat/config/app_config.dart';
@ -399,7 +399,7 @@ class _ChatState extends State<Chat> {
event.sendAgain();
}
final allEditEvents = event
.aggregatedEvents(timeline, RelationshipTypes.Edit)
.aggregatedEvents(timeline, RelationshipTypes.edit)
.where((e) => e.status == -1);
for (final e in allEditEvents) {
e.sendAgain();
@ -476,7 +476,7 @@ class _ChatState extends State<Chat> {
children: [
Spacer(),
EmojiPicker(
onEmojiSelected: (emoji, category) {
onEmojiSelected: (category, emoji) {
// recent emojis don't work, so we sadly have to re-implement them
// https://github.com/JeffG05/emoji_picker/issues/31
SharedPreferences.getInstance().then((prefs) {
@ -485,7 +485,7 @@ class _ChatState extends State<Chat> {
// make sure we remove duplicates
prefs.setStringList('recents', recents.toSet().toList());
});
Navigator.of(context, rootNavigator: false).pop<Emoji>(emoji);
Navigator.of(context, rootNavigator: false).pop(emoji);
},
),
],
@ -986,7 +986,7 @@ class _ChatState extends State<Chat> {
var emojis = List<String>.from(AppEmojis.emojis);
final allReactionEvents = selectedEvents.first
.aggregatedEvents(
timeline, RelationshipTypes.Reaction)
timeline, RelationshipTypes.reaction)
?.where((event) =>
event.senderId == event.room.client.userID &&
event.type == 'm.reaction');

View File

@ -413,8 +413,8 @@ class _ChatDetailsState extends State<ChatDetails> {
),
if (room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.world_readable,
child: Text(HistoryVisibility.world_readable
value: HistoryVisibility.worldReadable,
child: Text(HistoryVisibility.worldReadable
.getLocalizedString(
MatrixLocals(L10n.of(context)))),
),
@ -446,9 +446,9 @@ class _ChatDetailsState extends State<ChatDetails> {
<PopupMenuEntry<GuestAccess>>[
if (room.canChangeGuestAccess)
PopupMenuItem<GuestAccess>(
value: GuestAccess.can_join,
value: GuestAccess.canJoin,
child: Text(
GuestAccess.can_join.getLocalizedString(
GuestAccess.canJoin.getLocalizedString(
MatrixLocals(L10n.of(context))),
),
),

View File

@ -127,7 +127,7 @@ class _ChatListState extends State<ChatList> {
context: context,
future: () => room.setPushRuleState(
room.pushRuleState == PushRuleState.notify
? PushRuleState.mentions_only
? PushRuleState.mentionsOnly
: PushRuleState.notify),
);
}

View File

@ -1,7 +1,7 @@
import 'package:fluffychat/config/setting_keys.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_lock/flutter_app_lock.dart';
import 'package:flutter_screen_lock/lock_screen.dart';
import 'package:flutter_screen_lock/functions.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class LockScreen extends StatelessWidget {
@ -17,11 +17,10 @@ class LockScreen extends StatelessWidget {
if (snapshot.connectionState == ConnectionState.done) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (snapshot.data?.isNotEmpty ?? false) {
showLockScreen(
screenLock(
context: context,
correctString: snapshot.data,
onUnlocked: () => AppLock.of(context).didUnlock(),
canBiometric: true,
didConfirmed: (_) => AppLock.of(context).didUnlock(),
canCancel: false,
);
} else {

View File

@ -16,7 +16,7 @@ import 'package:fluffychat/utils/sentry_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_lock/flutter_app_lock.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_screen_lock/lock_screen.dart';
import 'package:flutter_screen_lock/functions.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:image_picker/image_picker.dart';
import 'package:url_launcher/url_launcher.dart';
@ -296,11 +296,10 @@ class _SettingsState extends State<Settings> {
await FlutterSecureStorage().read(key: SettingKeys.appLockKey);
if (currentLock?.isNotEmpty ?? false) {
var unlocked = false;
await showLockScreen(
await screenLock(
context: context,
correctString: currentLock,
onUnlocked: () => unlocked = true,
canBiometric: true,
didConfirmed: (_) => unlocked = true,
);
if (unlocked != true) return;
}

View File

@ -425,7 +425,7 @@ class _EmoteImage extends StatelessWidget {
method: ThumbnailMethod.scale,
);
return CachedNetworkImage(
imageUrl: url,
imageUrl: url.toString(),
fit: BoxFit.contain,
width: size,
height: size,

View File

@ -8,7 +8,7 @@ import 'package:fluffychat/views/widgets/message_download_content.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sound_lite/flutter_sound.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:universal_html/html.dart' as html;
import 'package:flutter_gen/gen_l10n/l10n.dart';
import '../../utils/ui_fake.dart' if (dart.library.html) 'dart:ui' as ui;
import 'matrix.dart';
@ -144,7 +144,8 @@ class _AudioPlayerState extends State<AudioPlayer> {
if (kIsWeb) {
if (widget.event.content['url'] is String) {
webSrcUrl = Uri.parse(widget.event.content['url'])
.getDownloadLink(Matrix.of(context).client);
.getDownloadLink(Matrix.of(context).client)
.toString();
return Container(
height: 50,
width: 300,

View File

@ -66,7 +66,7 @@ class Avatar extends StatelessWidget {
child: noPic
? textWidget
: CachedNetworkImage(
imageUrl: src,
imageUrl: src.toString(),
fit: BoxFit.cover,
width: size,
height: size,

View File

@ -86,7 +86,7 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
await showFutureLoadingDialog(
context: context,
future: () =>
widget.room.setPushRuleState(PushRuleState.mentions_only));
widget.room.setPushRuleState(PushRuleState.mentionsOnly));
break;
case 'unmute':
await showFutureLoadingDialog(

View File

@ -53,7 +53,7 @@ class ContentBanner extends StatelessWidget {
opacity: opacity,
child: (!loading && mxContent != null)
? CachedNetworkImage(
imageUrl: src,
imageUrl: src.toString(),
height: 300,
fit: BoxFit.cover,
)

View File

@ -56,13 +56,15 @@ class HtmlMessage extends StatelessWidget {
getMxcUrl: (String mxc, double width, double height,
{bool animated = false}) {
final ratio = MediaQuery.of(context).devicePixelRatio;
return Uri.parse(mxc)?.getThumbnail(
matrix.client,
width: (width ?? 800) * ratio,
height: (height ?? 800) * ratio,
method: ThumbnailMethod.scale,
animated: animated,
);
return Uri.parse(mxc)
?.getThumbnail(
matrix.client,
width: (width ?? 800) * ratio,
height: (height ?? 800) * ratio,
method: ThumbnailMethod.scale,
animated: animated,
)
.toString();
},
setCodeLanguage: (String key, String value) async {
await matrix.store.setItem('${SettingKeys.codeLanguage}.$key', value);

View File

@ -80,9 +80,10 @@ class _ImageBubbleState extends State<ImageBubble> {
@override
void initState() {
thumbnailUrl =
widget.event.getAttachmentUrl(getThumbnail: true, animated: true);
attachmentUrl = widget.event.getAttachmentUrl(animated: true);
thumbnailUrl = widget.event
.getAttachmentUrl(getThumbnail: true, animated: true)
.toString();
attachmentUrl = widget.event.getAttachmentUrl(animated: true).toString();
if (thumbnailUrl == null) {
_requestFile(getThumbnail: true);
}
@ -195,12 +196,15 @@ class _ImageBubbleState extends State<ImageBubble> {
_requestedThumbnailOnFailure = true;
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
thumbnailUrl = widget.event.getAttachmentUrl(
getThumbnail: true,
useThumbnailMxcUrl: true,
animated: true);
thumbnailUrl = widget.event
.getAttachmentUrl(
getThumbnail: true,
useThumbnailMxcUrl: true,
animated: true)
.toString();
attachmentUrl = widget.event
.getAttachmentUrl(useThumbnailMxcUrl: true, animated: true);
.getAttachmentUrl(useThumbnailMxcUrl: true, animated: true)
.toString();
});
});
}

View File

@ -160,7 +160,7 @@ class InputBar extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CachedNetworkImage(
imageUrl: url,
imageUrl: url.toString(),
width: size,
height: size,
),

View File

@ -92,7 +92,7 @@ class Message extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (event.relationshipType == RelationshipTypes.Reply)
if (event.relationshipType == RelationshipTypes.reply)
FutureBuilder<Event>(
future: event.getReplyEvent(timeline),
builder: (BuildContext context, snapshot) {
@ -177,7 +177,7 @@ class Message extends StatelessWidget {
children: rowChildren,
);
Widget container;
if (event.hasAggregatedEvents(timeline, RelationshipTypes.Reaction)) {
if (event.hasAggregatedEvents(timeline, RelationshipTypes.reaction)) {
container = Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
@ -253,7 +253,7 @@ class _MetaRow extends StatelessWidget {
fontSize: 11 * AppConfig.fontSizeFactor,
),
),
if (event.hasAggregatedEvents(timeline, RelationshipTypes.Edit))
if (event.hasAggregatedEvents(timeline, RelationshipTypes.edit))
Padding(
padding: const EdgeInsets.only(left: 2.0),
child: Icon(

View File

@ -16,7 +16,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:provider/provider.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:universal_html/html.dart' as html;
import 'package:http/http.dart' as http;
import 'package:url_launcher/url_launcher.dart';
/*import 'package:fluffychat/views/chat.dart';
@ -196,7 +196,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
html.Notification(
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context))),
body: body,
icon: icon,
icon: icon.toString(),
);
} else if (Platform.isLinux) {
/*var sessionBus = DBusClient.session();
@ -234,7 +234,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
Future<void> initConfig() async {
try {
var configJsonString =
utf8.decode((await http.get('config.json')).bodyBytes);
utf8.decode((await http.get(Uri.parse('config.json'))).bodyBytes);
final configJson = json.decode(configJsonString);
AppConfig.loadFromJson(configJson);
} catch (e, s) {

View File

@ -14,7 +14,7 @@ class MessageReactions extends StatelessWidget {
@override
Widget build(BuildContext context) {
final allReactionEvents =
event.aggregatedEvents(timeline, RelationshipTypes.Reaction);
event.aggregatedEvents(timeline, RelationshipTypes.reaction);
final reactionMap = <String, _ReactionEntry>{};
for (final e in allReactionEvents) {
if (e.content['m.relates_to'].containsKey('key')) {
@ -97,7 +97,7 @@ class _Reaction extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CachedNetworkImage(
imageUrl: src,
imageUrl: src.toString(),
height: fontSize,
),
Container(width: 4),

View File

@ -5,12 +5,16 @@
#include "generated_plugin_registrant.h"
#include <file_chooser/file_chooser_plugin.h>
#include <flutter_secure_storage/flutter_secure_storage_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_chooser_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileChooserPlugin");
file_chooser_plugin_register_with_registrar(file_chooser_registrar);
g_autoptr(FlPluginRegistrar) flutter_secure_storage_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStoragePlugin");
flutter_secure_storage_plugin_register_with_registrar(flutter_secure_storage_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);

View File

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
file_chooser
flutter_secure_storage
url_launcher_linux
)

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ dependencies:
famedlysdk:
git:
url: https://gitlab.com/famedly/famedlysdk.git
ref: main
ref: 0bad62971bee06c7c4a90e1564246c6325ae7d8f
unifiedpush:
git:
@ -24,40 +24,39 @@ dependencies:
fcm_shared_isolate:
git:
url: https://gitlab.com/famedly/libraries/fcm_shared_isolate.git
ref: ios
ref: 13ace9a4b4553c3c528448391f44d786f5243c57
firebase_messaging: any
cupertino_icons: any
localstorage: ^3.0.6+9
file_picker_cross: ^4.2.8
image_picker: ^0.6.7+21
url_launcher: ^5.7.10
cached_network_image: ^2.5.0
flutter_local_notifications: ^3.0.3
adaptive_page_layout: ^0.2.1
provider: ^4.3.3
adaptive_theme: ^1.1.0
localstorage: ^4.0.0+1
file_picker_cross: ^4.3.2
image_picker: ^0.7.4
url_launcher: ^6.0.3
cached_network_image: ^3.0.0
flutter_local_notifications: ^5.0.0+1
adaptive_page_layout: ^0.2.2
provider: ^5.0.0
adaptive_theme: ^2.1.1
# desktop_notifications: ^0.0.0-dev.4 // Currently blocked by: https://github.com/canonical/desktop_notifications.dart/issues/5
matrix_link_text: ^0.3.2
path_provider: ^1.6.27
android_path_provider: ^0.1.1
permission_handler: ^5.0.1+1
share: ^0.6.5+4
flutter_secure_storage: ^3.3.5
universal_html: ^1.2.4
receive_sharing_intent: ^1.4.3
path_provider: ^2.0.1
android_path_provider: ^0.2.1
permission_handler: ^6.1.1
share: ^2.0.1
flutter_secure_storage: ^4.1.0
universal_html: ^2.0.8
receive_sharing_intent: ^1.4.5
flutter_slidable: ^0.5.7
flutter_sound_lite: ^7.5.3+1
open_file: ^3.0.3
mime_type: ^0.3.2
adaptive_dialog: ^0.9.3
flutter_sound_lite: ^8.0.0+6
open_file: ^3.1.0
mime_type: ^1.0.0
adaptive_dialog: ^0.10.0+5
flutter_matrix_html:
git:
url: https://github.com/Sorunome/flutter_matrix_html.git
ref: 6b6a850fcfc3b0a3e88a3dd6beb79eda3acac853
moor: ^3.4.0
sqlite3: ^0.1.8
sqflite: ^1.3.2+2 # Still used to obtain the database location
flutter_typeahead: ^2.0.0
url: https://github.com/ChristianPauly/flutter_matrix_html.git
moor: ^4.2.1
sqlite3: ^1.0.0
sqflite: ^2.0.0+3 # Still used to obtain the database location
flutter_typeahead: ^3.1.1
flutter_olm: ^1.1.1
intl: any
circular_check_box: ^1.0.4
@ -67,34 +66,35 @@ dependencies:
git:
url: https://gitlab.com/famedly/libraries/native_imaging.git
ref: master
flutter_blurhash: ^0.5.0
flutter_blurhash: ^0.6.0
sentry: ">=3.0.0 <4.0.0"
scroll_to_index: ^1.0.6
scroll_to_index: ^2.0.0
swipe_to_action: ^0.1.0
flutter_svg: ^0.19.3
flutter_cache_manager: ^2.1.1
open_noti_settings: ^0.0.4
emoji_picker: ^0.1.0
flutter_svg: ^0.21.0+1
flutter_cache_manager: ^3.0.1
open_noti_settings: ^0.1.0
emoji_picker_flutter: ^1.0.3
future_loading_dialog: ^0.1.2
package_info: ^0.4.3+2
flutter_app_lock: ^1.4.0+1
flutter_screen_lock: ^1.2.6
email_validator: ^1.0.6
package_info: ^2.0.0
flutter_app_lock: ^1.5.0
flutter_screen_lock: ^4.0.3
email_validator: ^2.0.1
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.9.2
dapackages: ^1.4.0
pedantic: ^1.11.0
dapackages: ^1.6.0
# The flutter_maths version of flutter_matrix_html is weird and conflicts with a few of our packages.
# So, we have to force-override the dependencies to work out.
dependency_overrides:
provider: ^4.3.3
flutter_svg: ^0.19.3
# Was actually brought in via fcm packages and flutter_matrix_html
quiver: ^2.0.0
flutter_svg: ^0.21.0+1
shared_preferences: ^2.0.1
matrix_link_text:
git:
url: https://github.com/ChristianPauly/matrix_link_text.git
flutter:
generate: true