refactor: Migrate to null safety

This commit is contained in:
Krille Fear 2022-01-29 12:35:03 +01:00 committed by Christian Pauly
commit 55f0300f9f
163 changed files with 1759 additions and 1903 deletions

View file

@ -11,7 +11,7 @@ import 'settings_3pid_view.dart';
class Settings3Pid extends StatefulWidget {
static int sendAttempt = 0;
const Settings3Pid({Key key}) : super(key: key);
const Settings3Pid({Key? key}) : super(key: key);
@override
Settings3PidController createState() => Settings3PidController();
@ -22,12 +22,12 @@ class Settings3PidController extends State<Settings3Pid> {
final input = await showTextInputDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context).enterAnEmailAddress,
okLabel: L10n.of(context).ok,
cancelLabel: L10n.of(context).cancel,
title: L10n.of(context)!.enterAnEmailAddress,
okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel,
textFields: [
DialogTextField(
hintText: L10n.of(context).enterAnEmailAddress,
hintText: L10n.of(context)!.enterAnEmailAddress,
keyboardType: TextInputType.emailAddress,
),
],
@ -46,17 +46,17 @@ class Settings3PidController extends State<Settings3Pid> {
final ok = await showOkAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context).weSentYouAnEmail,
message: L10n.of(context).pleaseClickOnLink,
okLabel: L10n.of(context).iHaveClickedOnLink,
title: L10n.of(context)!.weSentYouAnEmail,
message: L10n.of(context)!.pleaseClickOnLink,
okLabel: L10n.of(context)!.iHaveClickedOnLink,
);
if (ok == null) return;
if (ok != OkCancelResult.ok) return;
final success = await showFutureLoadingDialog(
context: context,
future: () => Matrix.of(context).client.uiaRequestBackground(
(auth) => Matrix.of(context).client.add3PID(
clientSecret,
response.result.sid,
response.result!.sid,
auth: auth,
),
),
@ -65,15 +65,15 @@ class Settings3PidController extends State<Settings3Pid> {
setState(() => request = null);
}
Future<List<ThirdPartyIdentifier>> request;
Future<List<ThirdPartyIdentifier>?>? request;
void delete3Pid(ThirdPartyIdentifier identifier) async {
if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context,
title: L10n.of(context).areYouSure,
okLabel: L10n.of(context).yes,
cancelLabel: L10n.of(context).cancel,
title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.cancel,
) !=
OkCancelResult.ok) {
return;

View file

@ -10,7 +10,7 @@ import 'package:fluffychat/widgets/matrix.dart';
class Settings3PidView extends StatelessWidget {
final Settings3PidController controller;
const Settings3PidView(this.controller, {Key key}) : super(key: key);
const Settings3PidView(this.controller, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -18,20 +18,20 @@ class Settings3PidView extends StatelessWidget {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
title: Text(L10n.of(context).passwordRecovery),
title: Text(L10n.of(context)!.passwordRecovery),
actions: [
IconButton(
icon: const Icon(Icons.add_outlined),
onPressed: controller.add3PidAction,
tooltip: L10n.of(context).addEmail,
tooltip: L10n.of(context)!.addEmail,
)
],
),
body: MaxWidthBody(
child: FutureBuilder<List<ThirdPartyIdentifier>>(
child: FutureBuilder<List<ThirdPartyIdentifier>?>(
future: controller.request,
builder: (BuildContext context,
AsyncSnapshot<List<ThirdPartyIdentifier>> snapshot) {
AsyncSnapshot<List<ThirdPartyIdentifier>?> snapshot) {
if (snapshot.hasError) {
return Center(
child: Text(
@ -44,7 +44,7 @@ class Settings3PidView extends StatelessWidget {
return const Center(
child: CircularProgressIndicator.adaptive(strokeWidth: 2));
}
final identifier = snapshot.data;
final identifier = snapshot.data!;
return Column(
children: [
ListTile(
@ -60,8 +60,8 @@ class Settings3PidView extends StatelessWidget {
),
title: Text(
identifier.isEmpty
? L10n.of(context).noPasswordRecoveryDescription
: L10n.of(context)
? L10n.of(context)!.noPasswordRecoveryDescription
: L10n.of(context)!
.withTheseAddressesRecoveryDescription,
),
),
@ -77,7 +77,7 @@ class Settings3PidView extends StatelessWidget {
child: Icon(identifier[i].iconData)),
title: Text(identifier[i].address),
trailing: IconButton(
tooltip: L10n.of(context).delete,
tooltip: L10n.of(context)!.delete,
icon: const Icon(Icons.delete_forever_outlined),
color: Colors.red,
onPressed: () => controller.delete3Pid(identifier[i]),
@ -102,6 +102,5 @@ extension on ThirdPartyIdentifier {
case ThirdPartyIdentifierMedium.msisdn:
return Icons.phone_android_outlined;
}
return Icons.device_unknown_outlined;
}
}