refactor: Migrate to Flutter 3.7.0

This commit is contained in:
Christian Pauly 2023-01-26 09:47:30 +01:00
commit 35174cb859
54 changed files with 876 additions and 2124 deletions

View file

@ -30,8 +30,12 @@ extension LocalizedExceptionExtension on Object {
.toString()
.replaceAll('{', '"')
.replaceAll('}', '"');
return L10n.of(context)!
.badServerVersionsException(serverVersions, supportedVersions);
return L10n.of(context)!.badServerVersionsException(
serverVersions,
supportedVersions,
serverVersions,
supportedVersions,
);
}
if (this is BadServerLoginTypesException) {
final serverVersions = (this as BadServerLoginTypesException)
@ -44,8 +48,11 @@ extension LocalizedExceptionExtension on Object {
.toString()
.replaceAll('{', '"')
.replaceAll('}', '"');
return L10n.of(context)!
.badServerLoginTypesException(serverVersions, supportedVersions);
return L10n.of(context)!.badServerLoginTypesException(
serverVersions,
supportedVersions,
supportedVersions,
);
}
if (this is MatrixConnectionException || this is SocketException) {
return L10n.of(context)!.noConnectionToTheServer;

View file

@ -1,10 +1,8 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:image_picker/image_picker.dart';
import 'package:matrix/matrix.dart';
import 'package:path_provider/path_provider.dart';
import 'package:share_plus/share_plus.dart';
import 'package:fluffychat/utils/platform_infos.dart';
@ -22,17 +20,12 @@ extension MatrixFileExtension on MatrixFile {
}
void share(BuildContext context) async {
final fileName = name.split('/').last;
final tmpDirectory = await getTemporaryDirectory();
final path = '${tmpDirectory.path}$fileName';
await File(path).writeAsBytes(bytes);
// Workaround for iPad from
// https://github.com/fluttercommunity/plus_plugins/tree/main/packages/share_plus/share_plus#ipad
final box = context.findRenderObject() as RenderBox?;
await Share.shareFiles(
[path],
await Share.shareXFiles(
[XFile.fromData(bytes)],
sharePositionOrigin:
box == null ? null : box.localToGlobal(Offset.zero) & box.size,
);

View file

@ -19,7 +19,7 @@ class MatrixLocals extends MatrixLocalizations {
@override
String answeredTheCall(String senderName) {
return l10n.answeredTheCall(senderName);
return l10n.answeredTheCall(senderName, senderName);
}
@override
@ -245,7 +245,7 @@ class MatrixLocals extends MatrixLocalizations {
@override
String unknownEvent(String typeKey) {
return l10n.unknownEvent(typeKey);
return l10n.unknownEvent(typeKey, typeKey);
}
@override

View file

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:vrouter/vrouter.dart';
import '../config/app_config.dart';
@ -50,11 +50,11 @@ abstract class PlatformInfos {
children: [
Text('Version: $version'),
OutlinedButton(
onPressed: () => launch(AppConfig.sourceCodeUrl),
onPressed: () => launchUrlString(AppConfig.sourceCodeUrl),
child: Text(L10n.of(context)!.sourceCode),
),
OutlinedButton(
onPressed: () => launch(AppConfig.emojiFontUrl),
onPressed: () => launchUrlString(AppConfig.emojiFontUrl),
child: const Text(AppConfig.emojiFontName),
),
OutlinedButton(

View file

@ -3,7 +3,7 @@ import 'dart:async';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:fluffychat/widgets/matrix.dart';
@ -83,11 +83,7 @@ extension UiaRequestManager on MatrixState {
default:
final url = Uri.parse(
'${client.homeserver}/_matrix/client/r0/auth/$stage/fallback/web?session=${uiaRequest.session}');
launch(
url.toString(),
forceSafariVC: true,
forceWebView: false,
);
launchUrlString(url.toString());
if (OkCancelResult.ok ==
await showOkCancelAlertDialog(
useRootNavigator: false,

View file

@ -6,7 +6,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart';
import 'package:punycode/punycode.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/config/app_config.dart';
@ -56,17 +56,17 @@ class UrlLauncher {
// to an apple maps thingy
// https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
final ll = '${latlong.first},${latlong.last}';
launch('https://maps.apple.com/?q=$ll&sll=$ll');
launchUrlString('https://maps.apple.com/?q=$ll&sll=$ll');
} else {
// transmute geo URIs on desktop to openstreetmap links, as those usually can't handle
// geo URIs
launch(
launchUrlString(
'https://www.openstreetmap.org/?mlat=${latlong.first}&mlon=${latlong.last}#map=16/${latlong.first}/${latlong.last}');
}
return;
}
}
launch(url!);
launchUrlString(url!);
return;
}
if (uri.host.isEmpty) {
@ -84,7 +84,7 @@ class UrlLauncher {
? 'xn--$hostPartPunycode'
: hostPart;
}).join('.');
launch(uri.replace(host: newHost).toString());
launchUrlString(uri.replace(host: newHost).toString());
}
void openMatrixToUrl() async {

View file

@ -91,7 +91,7 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
overlayEntry = null;
}),
);
Overlay.of(context)!.insert(overlayEntry!);
Overlay.of(context).insert(overlayEntry!);
}
}