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

@ -14,19 +14,19 @@ import '../../widgets/matrix.dart';
import 'settings_view.dart';
class Settings extends StatefulWidget {
const Settings({Key key}) : super(key: key);
const Settings({Key? key}) : super(key: key);
@override
SettingsController createState() => SettingsController();
}
class SettingsController extends State<Settings> {
Future<bool> crossSigningCachedFuture;
bool crossSigningCached;
Future<bool> megolmBackupCachedFuture;
bool megolmBackupCached;
Future<dynamic> profileFuture;
Profile profile;
Future<bool>? crossSigningCachedFuture;
bool? crossSigningCached;
Future<bool>? megolmBackupCachedFuture;
bool? megolmBackupCached;
Future<dynamic>? profileFuture;
Profile? profile;
bool profileUpdated = false;
void updateProfile() => setState(() {
@ -39,19 +39,19 @@ class SettingsController extends State<Settings> {
if (PlatformInfos.isMobile)
SheetAction(
key: AvatarAction.camera,
label: L10n.of(context).openCamera,
label: L10n.of(context)!.openCamera,
isDefaultAction: true,
icon: Icons.camera_alt_outlined,
),
SheetAction(
key: AvatarAction.file,
label: L10n.of(context).openGallery,
label: L10n.of(context)!.openGallery,
icon: Icons.photo_outlined,
),
if (profile?.avatarUrl != null)
SheetAction(
key: AvatarAction.remove,
label: L10n.of(context).removeYourAvatar,
label: L10n.of(context)!.removeYourAvatar,
isDestructiveAction: true,
icon: Icons.delete_outlined,
),
@ -60,7 +60,7 @@ class SettingsController extends State<Settings> {
? actions.single
: await showModalActionSheet<AvatarAction>(
context: context,
title: L10n.of(context).changeYourAvatar,
title: L10n.of(context)!.changeYourAvatar,
actions: actions,
);
if (action == null) return;
@ -91,10 +91,10 @@ class SettingsController extends State<Settings> {
} else {
final result =
await FilePickerCross.importFromStorage(type: FileTypeCross.image);
if (result == null) return;
if (result.fileName == null) return;
file = MatrixFile(
bytes: result.toUint8List(),
name: result.fileName,
name: result.fileName!,
);
}
final success = await showFutureLoadingDialog(
@ -111,7 +111,7 @@ class SettingsController extends State<Settings> {
final client = Matrix.of(context).client;
profileFuture ??= client
.getProfileFromUserId(
client.userID,
client.userID!,
cache: !profileUpdated,
getFromRooms: !profileUpdated,
)
@ -121,12 +121,12 @@ class SettingsController extends State<Settings> {
});
if (client.encryption != null) {
crossSigningCachedFuture ??=
client.encryption?.crossSigning?.isCached()?.then((c) {
client.encryption?.crossSigning.isCached().then((c) {
if (mounted) setState(() => crossSigningCached = c);
return c;
});
megolmBackupCachedFuture ??=
client.encryption?.keyManager?.isCached()?.then((c) {
client.encryption?.keyManager.isCached().then((c) {
if (mounted) setState(() => megolmBackupCached = c);
return c;
});

View file

@ -13,7 +13,7 @@ import 'settings.dart';
class SettingsView extends StatelessWidget {
final SettingsController controller;
const SettingsView(this.controller, {Key key}) : super(key: key);
const SettingsView(this.controller, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -25,11 +25,11 @@ class SettingsView extends StatelessWidget {
expandedHeight: 300.0,
floating: true,
pinned: true,
title: Text(L10n.of(context).settings),
title: Text(L10n.of(context)!.settings),
backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
flexibleSpace: FlexibleSpaceBar(
background: ContentBanner(
controller.profile?.avatarUrl,
mxContent: controller.profile?.avatarUrl,
onEdit: controller.setAvatarAction,
defaultIcon: Icons.person_outline_outlined,
),
@ -37,54 +37,54 @@ class SettingsView extends StatelessWidget {
),
],
body: ListTileTheme(
iconColor: Theme.of(context).textTheme.bodyText1.color,
iconColor: Theme.of(context).textTheme.bodyText1!.color,
child: ListView(
children: <Widget>[
ListTile(
leading: const Icon(Icons.format_paint_outlined),
title: Text(L10n.of(context).changeTheme),
title: Text(L10n.of(context)!.changeTheme),
onTap: () => VRouter.of(context).to('/settings/style'),
),
const Divider(thickness: 1),
ListTile(
leading: const Icon(Icons.notifications_outlined),
title: Text(L10n.of(context).notifications),
title: Text(L10n.of(context)!.notifications),
onTap: () => VRouter.of(context).to('/settings/notifications'),
),
ListTile(
leading: const Icon(Icons.devices_outlined),
title: Text(L10n.of(context).devices),
title: Text(L10n.of(context)!.devices),
onTap: () => VRouter.of(context).to('/settings/devices'),
),
ListTile(
leading: const Icon(Icons.chat_bubble_outline_outlined),
title: Text(L10n.of(context).chat),
title: Text(L10n.of(context)!.chat),
onTap: () => VRouter.of(context).to('/settings/chat'),
),
ListTile(
leading: const Icon(Icons.account_circle_outlined),
title: Text(L10n.of(context).account),
title: Text(L10n.of(context)!.account),
onTap: () => VRouter.of(context).to('/settings/account'),
),
ListTile(
leading: const Icon(Icons.shield_outlined),
title: Text(L10n.of(context).security),
title: Text(L10n.of(context)!.security),
onTap: () => VRouter.of(context).to('/settings/security'),
),
const Divider(thickness: 1),
ListTile(
leading: const Icon(Icons.help_outline_outlined),
title: Text(L10n.of(context).help),
title: Text(L10n.of(context)!.help),
onTap: () => launch(AppConfig.supportUrl),
),
ListTile(
leading: const Icon(Icons.shield_sharp),
title: Text(L10n.of(context).privacy),
title: Text(L10n.of(context)!.privacy),
onTap: () => launch(AppConfig.privacyUrl),
),
ListTile(
leading: const Icon(Icons.info_outline_rounded),
title: Text(L10n.of(context).about),
title: Text(L10n.of(context)!.about),
onTap: () => PlatformInfos.showDialog(context),
),
],