1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-20 16:55:17 +00:00

Start to fix null safety migration errors

This commit is contained in:
2022-03-10 19:39:57 +01:00
parent ab2c5da0da
commit 3a997cdc56
258 changed files with 2879 additions and 2912 deletions

View File

@ -24,16 +24,16 @@ class AboutApplicationSettings extends StatelessWidget {
tiles: [
SettingsTile(
title: tr("Privacy policy"),
onPressed: (c) => launch(srvConfig.privacyPolicyURL),
onPressed: (c) => launch(srvConfig!.privacyPolicyURL),
),
SettingsTile(
title: tr("Terms of Use"),
onPressed: (c) => launch(srvConfig.termsURL),
onPressed: (c) => launch(srvConfig!.termsURL),
),
SettingsTile(
title: tr("Contact us"),
subtitle: srvConfig.contactEmail,
trailing: CopyIcon(srvConfig.contactEmail),
subtitle: srvConfig!.contactEmail,
trailing: CopyIcon(srvConfig!.contactEmail),
),
SettingsTile(
title: tr("About this application"),

View File

@ -30,7 +30,7 @@ class AccountImageSettingsScreen extends StatefulWidget {
class _AccountImageSettingsScreenState
extends State<AccountImageSettingsScreen> {
AccountImageSettings _settings;
late AccountImageSettings _settings;
final _key = GlobalKey<AsyncScreenWidgetState>();
@ -49,7 +49,7 @@ class _AccountImageSettingsScreenState
onReload: () async =>
_settings = await SettingsHelper.getAccountImageSettings(),
onBuild: () => _buildLayout(),
errorMessage: tr("Could not get account image settings!"),
errorMessage: tr("Could not get account image settings!")!,
);
}
@ -96,19 +96,19 @@ class _AccountImageSettingsScreenState
[
MultiChoiceEntry(
id: AccountImageVisibilityLevels.EVERYONE,
title: tr("Everyone"),
title: tr("Everyone")!,
subtitle: tr(
"Your account image is visible by everyone, including users external to Comunic."),
),
MultiChoiceEntry(
id: AccountImageVisibilityLevels.COMUNIC_USERS,
title: tr("Connected users"),
title: tr("Connected users")!,
subtitle: tr(
"Your account image is visible only to connected Comunic users."),
),
MultiChoiceEntry(
id: AccountImageVisibilityLevels.FRIENDS_ONLY,
title: tr("My friends"),
title: tr("My friends")!,
subtitle: tr("Your account image is visible only by your friends."),
),
];
@ -139,14 +139,14 @@ class _AccountImageSettingsScreenState
// Change account image visibility
MultiChoicesSettingsTile(
title: tr("Account image visibility"),
title: tr("Account image visibility")!,
choices: _visibilityLevels,
currentValue: _settings.visibility,
onChanged: (newLevel) async {
onChanged: (dynamic newLevel) async {
if (!await SettingsHelper.setAccountImageVisibilityLevel(newLevel))
showSimpleSnack(context,
tr("Could not update account image visibility level!"));
_key.currentState.refresh();
tr("Could not update account image visibility level!")!);
_key.currentState!.refresh();
}),
// Delete account image
@ -160,7 +160,7 @@ class _AccountImageSettingsScreenState
/// Upload a new account image
void _uploadAccountImage() async {
await uploadNewAccountImage(context);
_key.currentState.refresh();
_key.currentState!.refresh();
}
/// Generate a random account image
@ -170,11 +170,11 @@ class _AccountImageSettingsScreenState
if (!await SettingsHelper.uploadAccountImageFromMemory(bytes)) {
showSimpleSnack(
context, tr("Could not upload your generated account image!"));
context, tr("Could not upload your generated account image!")!);
return;
}
_key.currentState.refresh();
_key.currentState!.refresh();
}
/// Delete user account image
@ -185,11 +185,11 @@ class _AccountImageSettingsScreenState
return;
if (!await SettingsHelper.deleteAccountImage()) {
showSimpleSnack(context, tr("Could not delete user account image!"));
showSimpleSnack(context, tr("Could not delete user account image!")!);
return;
}
_key.currentState.refresh();
_key.currentState!.refresh();
}
}
@ -203,6 +203,6 @@ Future<void> uploadNewAccountImage(BuildContext context) async {
await SettingsHelper.uploadAccountImage(image);
} catch (e, s) {
logError(e, s);
snack(context, tr("Failed to upload new account image!"));
snack(context, tr("Failed to upload new account image!")!);
}
}

View File

@ -25,9 +25,9 @@ class AccountPrivacySettings extends StatefulWidget {
class _AccountPrivacySettingsState extends State<AccountPrivacySettings> {
final _key = GlobalKey<AsyncScreenWidgetState>();
ServerConfig _serverConfig;
DataConservationPolicySettings _userSettings;
String _cachedPassword;
ServerConfig? _serverConfig;
late DataConservationPolicySettings _userSettings;
String? _cachedPassword;
Future<void> _loadSettings() async {
_serverConfig = ServerConfigurationHelper.config;
@ -59,68 +59,68 @@ class _AccountPrivacySettingsState extends State<AccountPrivacySettings> {
)
])
]),
errorMessage: tr("Failed to load privacy settings!"),
errorMessage: tr("Failed to load privacy settings!")!,
);
}
List<SettingsTile> get _dataConservationPolicyTiles => [
DataConservationPolicyTile(
value: _userSettings.notificationLifetime,
title: tr("Automatically delete unread notifications after"),
title: tr("Automatically delete unread notifications after")!,
onChange: (val) {
_userSettings.notificationLifetime = val;
_updateDataConservationPolicy();
},
minValue:
_serverConfig.dataConservationPolicy.minNotificationLifetime,
_serverConfig!.dataConservationPolicy.minNotificationLifetime,
),
DataConservationPolicyTile(
value: _userSettings.commentsLifetime,
title: tr("Automatically delete your comments after"),
title: tr("Automatically delete your comments after")!,
onChange: (val) {
_userSettings.commentsLifetime = val;
_updateDataConservationPolicy();
},
minValue: _serverConfig.dataConservationPolicy.minCommentsLifetime,
minValue: _serverConfig!.dataConservationPolicy.minCommentsLifetime,
),
DataConservationPolicyTile(
value: _userSettings.postsLifetime,
title: tr("Automatically delete your posts after"),
title: tr("Automatically delete your posts after")!,
onChange: (val) {
_userSettings.postsLifetime = val;
_updateDataConservationPolicy();
},
minValue: _serverConfig.dataConservationPolicy.minPostsLifetime,
minValue: _serverConfig!.dataConservationPolicy.minPostsLifetime,
),
DataConservationPolicyTile(
value: _userSettings.conversationMessagesLifetime,
title: tr("Automatically delete your conversation messages after"),
title: tr("Automatically delete your conversation messages after")!,
onChange: (val) {
_userSettings.conversationMessagesLifetime = val;
_updateDataConservationPolicy();
},
minValue: _serverConfig
minValue: _serverConfig!
.dataConservationPolicy.minConversationMessagesLifetime,
),
DataConservationPolicyTile(
value: _userSettings.likesLifetime,
title: tr("Automatically delete your likes after"),
title: tr("Automatically delete your likes after")!,
onChange: (val) {
_userSettings.likesLifetime = val;
_updateDataConservationPolicy();
},
minValue: _serverConfig.dataConservationPolicy.minLikesLifetime,
minValue: _serverConfig!.dataConservationPolicy.minLikesLifetime,
),
DataConservationPolicyTile(
value: _userSettings.inactiveAccountLifeTime,
title: tr(
"Automatically delete your account if you have been inactive for"),
"Automatically delete your account if you have been inactive for")!,
onChange: (val) {
_userSettings.inactiveAccountLifeTime = val;
_updateDataConservationPolicy();
},
minValue:
_serverConfig.dataConservationPolicy.minInactiveAccountLifetime,
_serverConfig!.dataConservationPolicy.minInactiveAccountLifetime,
),
];
@ -132,11 +132,11 @@ class _AccountPrivacySettingsState extends State<AccountPrivacySettings> {
await SettingsHelper.setDataConservationPolicy(
_cachedPassword, _userSettings);
_key.currentState.refresh();
_key.currentState!.refresh();
} catch (e, s) {
print("Could not update data conservation policy! $e\n$s");
showSimpleSnack(
context, tr("Failed to update data conservation policy!"));
context, tr("Failed to update data conservation policy!")!);
}
}
@ -164,22 +164,22 @@ class _AccountPrivacySettingsState extends State<AccountPrivacySettings> {
await AccountHelper.deleteAccount(password);
} catch (e, stack) {
print("Could not delete user account! $e\n$stack");
showSimpleSnack(context, tr("Could not delete your account!"));
showSimpleSnack(context, tr("Could not delete your account!")!);
}
}
}
class DataConservationPolicyTile extends SettingsTile {
final int value;
final int? value;
final String title;
final Function(int) onChange;
final int minValue;
DataConservationPolicyTile({
@required this.value,
@required this.title,
@required this.onChange,
@required this.minValue,
required this.value,
required this.title,
required this.onChange,
required this.minValue,
}) : assert(title != null),
assert(onChange != null),
assert(minValue != null);
@ -203,59 +203,59 @@ class DataConservationPolicyTile extends SettingsTile {
int get _roundValue {
if (this.value == null) return 0;
return _choices.firstWhere((element) => element.id >= this.value).id;
return _choices.firstWhere((element) => element.id >= this.value!).id;
}
List<MultiChoiceEntry<int>> get _choices => [
MultiChoiceEntry(id: 0, title: tr("Never"), hidden: false),
MultiChoiceEntry(id: 0, title: tr("Never")!, hidden: false),
MultiChoiceEntry(
id: _day * 7,
title: tr("7 days"),
title: tr("7 days")!,
hidden: _day * 7 < minValue,
),
MultiChoiceEntry(
id: _day * 15,
title: tr("15 days"),
title: tr("15 days")!,
hidden: _day * 15 < minValue,
),
MultiChoiceEntry(
id: _month,
title: tr("1 month"),
title: tr("1 month")!,
hidden: _month < minValue,
),
MultiChoiceEntry(
id: _month * 3,
title: tr("3 months"),
title: tr("3 months")!,
hidden: _month * 3 < minValue,
),
MultiChoiceEntry(
id: _month * 6,
title: tr("6 months"),
title: tr("6 months")!,
hidden: _month * 6 < minValue,
),
MultiChoiceEntry(
id: _year,
title: tr("1 year"),
title: tr("1 year")!,
hidden: _year < minValue,
),
MultiChoiceEntry(
id: _year * 2,
title: tr("2 years"),
title: tr("2 years")!,
hidden: _year * 5 < minValue,
),
MultiChoiceEntry(
id: _year * 5,
title: tr("5 years"),
title: tr("5 years")!,
hidden: _year * 5 < minValue,
),
MultiChoiceEntry(
id: _year * 10,
title: tr("10 years"),
title: tr("10 years")!,
hidden: _year * 10 < minValue,
),
MultiChoiceEntry(
id: _year * 50,
title: tr("50 years"),
title: tr("50 years")!,
hidden: _year * 50 < minValue,
),
];
@ -265,18 +265,18 @@ class _LastChanceDeleteAccountDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoAlertDialog(
title: Text(tr("Delete your account")),
title: Text(tr("Delete your account")!),
content: Text(tr(
"Let us ask you one last time. Do you really want to delete your account? If you decide to do so, your data will be permanently removed from our servers, so we will not be able to recover your account. If you decide to proceed, the deletion process will start immediatly and you will automatically get disconnected from your account.")),
"Let us ask you one last time. Do you really want to delete your account? If you decide to do so, your data will be permanently removed from our servers, so we will not be able to recover your account. If you decide to proceed, the deletion process will start immediatly and you will automatically get disconnected from your account.")!),
actions: <Widget>[
CupertinoDialogAction(
isDefaultAction: true,
child: Text(tr("Cancel")),
child: Text(tr("Cancel")!),
onPressed: () => Navigator.of(context).pop(false),
),
CupertinoDialogAction(
isDestructiveAction: true,
child: Text(tr("Confirm")),
child: Text(tr("Confirm")!),
onPressed: () => Navigator.of(context).pop(true),
),
],

View File

@ -86,10 +86,10 @@ class _AccountSecuritySettingsScreenState
await SettingsHelper.changePassword(currPassword, newPassword);
showSimpleSnack(
context, tr("Your password has been successfully changed!"));
context, tr("Your password has been successfully changed!")!);
} catch (e, stack) {
print("Could not update current user password! $e\n$stack");
showSimpleSnack(context, tr("Could not update password!"));
showSimpleSnack(context, tr("Could not update password!")!);
}
}
@ -111,10 +111,10 @@ class _AccountSecuritySettingsScreenState
await SettingsHelper.setSecuritySettings(password, newSettings);
showSimpleSnack(context,
tr("You security questions have been successfully updated!"));
tr("You security questions have been successfully updated!")!);
} catch (e, stack) {
print("Could not update security questions!$e\n$stack");
showSimpleSnack(context, tr("Could not update security questions!"));
showSimpleSnack(context, tr("Could not update security questions!")!);
}
}
@ -131,7 +131,7 @@ class _AccountSecuritySettingsScreenState
} catch (e, stack) {
print("Could not disconnect user on all devices! $e\n$stack");
showSimpleSnack(
context, tr("Could not disconnect you from all your devices!"));
context, tr("Could not disconnect you from all your devices!")!);
}
}
}
@ -139,7 +139,7 @@ class _AccountSecuritySettingsScreenState
class _SecurityQuestionsDialog extends StatefulWidget {
final SecuritySettings settings;
const _SecurityQuestionsDialog({Key key, @required this.settings})
const _SecurityQuestionsDialog({Key? key, required this.settings})
: assert(settings != null),
super(key: key);
@ -149,10 +149,10 @@ class _SecurityQuestionsDialog extends StatefulWidget {
}
class __SecurityQuestionsDialogState extends State<_SecurityQuestionsDialog> {
TextEditingController _controllerQuestion1;
TextEditingController _controllerAnswer1;
TextEditingController _controllerQuestion2;
TextEditingController _controllerAnswer2;
late TextEditingController _controllerQuestion1;
late TextEditingController _controllerAnswer1;
late TextEditingController _controllerQuestion2;
late TextEditingController _controllerAnswer2;
SecuritySettings get _newSettings => SecuritySettings(
securityQuestion1: _controllerQuestion1.text,
@ -177,16 +177,16 @@ class __SecurityQuestionsDialogState extends State<_SecurityQuestionsDialog> {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(tr("Update security questions")),
title: Text(tr("Update security questions")!),
content: AutoSizeDialogContentWidget(child: _buildContent()),
actions: <Widget>[
MaterialButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(tr("Cancel").toUpperCase()),
child: Text(tr("Cancel")!.toUpperCase()),
),
MaterialButton(
onPressed: () => Navigator.of(context).pop(_newSettings),
child: Text(tr("Update").toUpperCase()),
child: Text(tr("Update")!.toUpperCase()),
)
],
);
@ -196,7 +196,7 @@ class __SecurityQuestionsDialogState extends State<_SecurityQuestionsDialog> {
return Column(
children: <Widget>[
Text(tr(
"Note: Your two questions and answers MUST be completed in order to be able to recover your account using your security questions!")),
"Note: Your two questions and answers MUST be completed in order to be able to recover your account using your security questions!")!),
_buildTextField(
controller: _controllerQuestion1, label: tr("Question 1")),
_buildTextField(controller: _controllerAnswer1, label: tr("Answer 1")),
@ -208,8 +208,8 @@ class __SecurityQuestionsDialogState extends State<_SecurityQuestionsDialog> {
}
Widget _buildTextField({
@required TextEditingController controller,
@required String label,
required TextEditingController controller,
required String? label,
}) {
return TextField(
controller: controller,

View File

@ -27,10 +27,10 @@ class _SettingsSection {
final Widget Function() onBuild;
const _SettingsSection({
@required this.title,
@required this.subtitle,
@required this.icon,
@required this.onBuild,
required this.title,
required this.subtitle,
required this.icon,
required this.onBuild,
}) : assert(title != null),
assert(subtitle != null),
assert(icon != null),
@ -42,14 +42,14 @@ class AccountSettingsRoute extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(tr("Settings")),
title: Text(tr("Settings")!),
actions: [
PopupMenuButton<_MainMenuActions>(
onSelected: (v) => _doPopupMenuAction(context, v),
itemBuilder: (c) => [
PopupMenuItem(
value: _MainMenuActions.SHOW_TOUR,
child: Text(tr("See the tour again")),
child: Text(tr("See the tour again")!),
),
]),
],
@ -74,7 +74,7 @@ class _AccountSettingsBody extends StatefulWidget {
}
class __AccountSettingsBodyState extends State<_AccountSettingsBody> {
_SettingsSection _currentSection;
late _SettingsSection _currentSection;
@override
void initState() {
@ -87,64 +87,64 @@ class __AccountSettingsBodyState extends State<_AccountSettingsBody> {
/// The list of settings sections
List<_SettingsSection> get _sections => [
_SettingsSection(
title: tr("General settings"),
subtitle: tr("Configure the main settings of your account"),
title: tr("General settings")!,
subtitle: tr("Configure the main settings of your account")!,
icon: Icons.settings,
onBuild: () => GeneralAccountSettingsScreen(),
),
// Emoticons
_SettingsSection(
title: tr("Custom emojis"),
subtitle: tr("Set your own emoticon shorcuts"),
title: tr("Custom emojis")!,
subtitle: tr("Set your own emoticon shorcuts")!,
icon: Icons.insert_emoticon,
onBuild: () => CustomEmojisAccountSettings(),
),
// Account image
_SettingsSection(
title: tr("Account image"),
subtitle: tr("Customize your account image"),
title: tr("Account image")!,
subtitle: tr("Customize your account image")!,
icon: Icons.account_circle,
onBuild: () => AccountImageSettingsScreen(),
),
// Notifications settings
_SettingsSection(
title: tr("Notifications"),
subtitle: tr("Choose the notifications you receive on your phone"),
title: tr("Notifications")!,
subtitle: tr("Choose the notifications you receive on your phone")!,
icon: Icons.notifications,
onBuild: () => NotificationsSettingsScreen(),
),
// Security settings
_SettingsSection(
title: tr("Security"),
subtitle: tr("Manage security options of your account"),
title: tr("Security")!,
subtitle: tr("Manage security options of your account")!,
icon: Icons.lock,
onBuild: () => AccountSecuritySettingsScreen(),
),
// Privacy settings
_SettingsSection(
title: tr("Privacy"),
subtitle: tr("Here you can make actions to protect your privacy"),
title: tr("Privacy")!,
subtitle: tr("Here you can make actions to protect your privacy")!,
icon: Icons.security,
onBuild: () => AccountPrivacySettings(),
),
// Application settings
_SettingsSection(
title: tr("Application settings"),
subtitle: tr("Manage local application settings"),
title: tr("Application settings")!,
subtitle: tr("Manage local application settings")!,
icon: Icons.smartphone,
onBuild: () => ApplicationSettings(),
),
// About settings
_SettingsSection(
title: tr("About this application"),
subtitle: tr("Learn more about us"),
title: tr("About this application")!,
subtitle: tr("Learn more about us")!,
icon: Icons.info,
onBuild: () => AboutApplicationSettings(),
),

View File

@ -17,7 +17,7 @@ class ApplicationSettings extends StatefulWidget {
}
class _ApplicationSettingsState extends State<ApplicationSettings> {
PreferencesHelper _preferencesHelper;
PreferencesHelper? _preferencesHelper;
Future<void> _refresh() async {
_preferencesHelper = await PreferencesHelper.getInstance();
@ -27,7 +27,7 @@ class _ApplicationSettingsState extends State<ApplicationSettings> {
Widget build(BuildContext context) => AsyncScreenWidget(
onReload: _refresh,
onBuild: _buildSections,
errorMessage: tr("Could not load settings!"));
errorMessage: tr("Could not load settings!")!);
Widget _buildSections() {
return SettingsList(
@ -89,17 +89,17 @@ class _ApplicationSettingsState extends State<ApplicationSettings> {
class _PreferencesSettingsTile extends SettingsTile {
final PreferencesKeyList preferencesKey;
final String title;
final String subtitle;
final String? title;
final String? subtitle;
final Function onChange;
final PreferencesHelper helper;
final PreferencesHelper? helper;
_PreferencesSettingsTile({
@required this.preferencesKey,
@required this.title,
@required this.subtitle,
@required this.onChange,
@required this.helper,
required this.preferencesKey,
required this.title,
required this.subtitle,
required this.onChange,
required this.helper,
});
@override
@ -108,14 +108,14 @@ class _PreferencesSettingsTile extends SettingsTile {
title: title,
subtitle: subtitle,
onToggle: _doChange,
switchValue: helper.getBool(preferencesKey),
switchValue: helper!.getBool(preferencesKey),
titleMaxLines: 2,
subtitleMaxLines: 4,
);
}
void _doChange(bool value) async {
await helper.setBool(preferencesKey, value);
await helper!.setBool(preferencesKey, value);
onChange();
}
}

View File

@ -28,7 +28,7 @@ class CustomEmojisAccountSettings extends StatefulWidget {
class _CustomEmojisAccountSettingsState
extends State<CustomEmojisAccountSettings> {
User _user;
late User _user;
final _key = GlobalKey<AsyncScreenWidgetState>();
@ -45,7 +45,7 @@ class _CustomEmojisAccountSettingsState
key: _key,
onReload: _reload,
onBuild: _buildSettings,
errorMessage: tr("Could not refresh user information!"),
errorMessage: tr("Could not refresh user information!")!,
showOldDataWhileUpdating: true,
);
}
@ -63,8 +63,8 @@ class _CustomEmojisAccountSettingsState
return ListView(
children: _user.customEmojies
.map((u) => ListTile(
leading: NetworkImageWidget(url: u.url, width: 50),
title: Text(u.shortcut),
leading: NetworkImageWidget(url: u.url!, width: 50),
title: Text(u.shortcut!),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () => _deleteEmoji(u)),
@ -98,10 +98,10 @@ class _CustomEmojisAccountSettingsState
await SettingsHelper.uploadNewCustomEmoji(newEmoji);
} catch (e, stack) {
print("Could not add a new emoji: $e\n$stack");
showSimpleSnack(context, tr("Could not upload emoji!"));
showSimpleSnack(context, tr("Could not upload emoji!")!);
}
_key.currentState.refresh();
_key.currentState!.refresh();
}
/// Ask for confirmation before deleting permanently an emoji
@ -115,10 +115,10 @@ class _CustomEmojisAccountSettingsState
await SettingsHelper.deleteCustomEmoji(u.id);
} catch (e, stack) {
print("Could not delete custom emoji! $e\n$stack");
showSimpleSnack(context, tr("Could not delete custom emoji!"));
showSimpleSnack(context, tr("Could not delete custom emoji!")!);
}
_key.currentState.refresh();
_key.currentState!.refresh();
}
}
@ -127,8 +127,8 @@ class _NewCustomEmojiDialog extends StatefulWidget {
final CustomEmojiesList currentList;
const _NewCustomEmojiDialog({
Key key,
@required this.currentList,
Key? key,
required this.currentList,
}) : assert(currentList != null),
super(key: key);
@ -138,7 +138,7 @@ class _NewCustomEmojiDialog extends StatefulWidget {
class _NewCustomEmojiDialogState extends State<_NewCustomEmojiDialog> {
final _controller = TextEditingController();
BytesFile _file;
BytesFile? _file;
bool get _hasImage => _file != null;
@ -151,12 +151,12 @@ class _NewCustomEmojiDialogState extends State<_NewCustomEmojiDialog> {
bool get _valid => _hasImage && _shortcutValid;
NewEmoji get _emoji => NewEmoji(shortcut: _shortcut, image: _file);
NewEmoji get _emoji => NewEmoji(shortcut: _shortcut, image: _file!);
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(tr("Add new emoji")),
title: Text(tr("Add new emoji")!),
content: ConstrainedBox(
constraints:
BoxConstraints(maxHeight: MediaQuery.of(context).size.height - 50),
@ -167,11 +167,11 @@ class _NewCustomEmojiDialogState extends State<_NewCustomEmojiDialog> {
actions: <Widget>[
MaterialButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(tr("Cancel").toUpperCase()),
child: Text(tr("Cancel")!.toUpperCase()),
),
MaterialButton(
onPressed: _valid ? () => Navigator.of(context).pop(_emoji) : null,
child: Text(tr("Add").toUpperCase()),
child: Text(tr("Add")!.toUpperCase()),
),
],
);
@ -194,7 +194,7 @@ class _NewCustomEmojiDialogState extends State<_NewCustomEmojiDialog> {
),
MaterialButton(
onPressed: _pickImage,
child: Text(_hasImage ? tr("Replace image") : tr("Add image")),
child: Text(_hasImage ? tr("Replace image")! : tr("Add image")!),
)
],
);
@ -211,7 +211,7 @@ class _NewCustomEmojiDialogState extends State<_NewCustomEmojiDialog> {
});
} catch (e, stack) {
print("Could not pick an image! $e\n$stack");
snack(context, tr("Failed to pick an image!"));
snack(context, tr("Failed to pick an image!")!);
}
}
}

View File

@ -28,7 +28,7 @@ class GeneralAccountSettingsScreen extends StatefulWidget {
class _GeneralAccountSettingsScreenState
extends State<GeneralAccountSettingsScreen> {
GeneralSettings _settings;
late GeneralSettings _settings;
final _key = GlobalKey<AsyncScreenWidgetState>();
@ -47,7 +47,7 @@ class _GeneralAccountSettingsScreenState
onReload: () async =>
_settings = await SettingsHelper.getGeneralSettings(),
onBuild: _buildSettings,
errorMessage: tr("Could not load general settings!"),
errorMessage: tr("Could not load general settings!")!,
showOldDataWhileUpdating: true,
);
}
@ -81,28 +81,28 @@ class _GeneralAccountSettingsScreenState
// First name
TextEditSettingsTile(
title: tr("First name"),
title: tr("First name")!,
currValue: _settings.firstName,
onChanged: (s) {
_settings.firstName = s;
_updateSettings();
},
maxLength: srvConfig.accountInformationPolicy.maxFirstNameLength,
maxLength: srvConfig!.accountInformationPolicy.maxFirstNameLength,
checkInput: (s) =>
s.length >= srvConfig.accountInformationPolicy.minFirstNameLength,
s.length >= srvConfig!.accountInformationPolicy.minFirstNameLength,
),
// Last name
TextEditSettingsTile(
title: tr("Last name"),
title: tr("Last name")!,
currValue: _settings.lastName,
onChanged: (s) {
_settings.lastName = s;
_updateSettings();
},
maxLength: srvConfig.accountInformationPolicy.maxLastNameLength,
maxLength: srvConfig!.accountInformationPolicy.maxLastNameLength,
checkInput: (s) =>
s.length >= srvConfig.accountInformationPolicy.minLastNameLength,
s.length >= srvConfig!.accountInformationPolicy.minLastNameLength,
),
// Emails settings
@ -121,15 +121,15 @@ class _GeneralAccountSettingsScreenState
List<MultiChoiceEntry> get _visibilityChoices => [
MultiChoiceEntry(
id: UserPageVisibility.PRIVATE,
title: tr("Private"),
title: tr("Private")!,
subtitle: tr("Private, accessible only to your friends")),
MultiChoiceEntry(
id: UserPageVisibility.PUBLIC,
title: tr("Public"),
title: tr("Public")!,
subtitle: tr("Public, accessible to all Comunic members")),
MultiChoiceEntry(
id: UserPageVisibility.OPEN,
title: tr("Open"),
title: tr("Open")!,
subtitle:
tr("Accessible to everyone, including non-Comunic users")),
];
@ -139,10 +139,10 @@ class _GeneralAccountSettingsScreenState
return [
// Page visibility
MultiChoicesSettingsTile(
title: tr("Page visibility"),
title: tr("Page visibility")!,
choices: _visibilityChoices,
currentValue: _settings.pageVisibility,
onChanged: (v) {
onChanged: (dynamic v) {
_settings.pageVisibility = v;
_updateSettings();
}),
@ -191,7 +191,7 @@ class _GeneralAccountSettingsScreenState
// Personal website
TextEditSettingsTile(
title: tr("Personal website URL (optional)"),
title: tr("Personal website URL (optional)")!,
currValue: _settings.personalWebsite,
onChanged: (v) {
_settings.personalWebsite = v;
@ -203,19 +203,19 @@ class _GeneralAccountSettingsScreenState
// Location
TextEditSettingsTile(
title: tr("Location (optional)"),
title: tr("Location (optional)")!,
currValue: _settings.location ?? "",
onChanged: (v) {
_settings.location = v;
_updateSettings();
},
maxLength: srvConfig.accountInformationPolicy.maxLocationLength,
maxLength: srvConfig!.accountInformationPolicy.maxLocationLength,
allowEmptyValues: true,
),
// Public notes
TextEditSettingsTile(
title: tr("Public note (optional)"),
title: tr("Public note (optional)")!,
currValue: _settings.publicNote,
onChanged: (v) {
_settings.publicNote = v;
@ -235,7 +235,7 @@ class _GeneralAccountSettingsScreenState
context: context,
initialDirectory: _settings.virtualDirectory,
type: VirtualDirectoryTargetType.USER,
id: userID());
id: userID()!);
if (dir == null) return;
@ -252,8 +252,8 @@ class _GeneralAccountSettingsScreenState
await SettingsHelper.updateGeneralSettings(_settings);
} catch (e, stack) {
print("Error while updating settings! $e/n$stack");
showSimpleSnack(context, tr("Could not update general settings!"));
showSimpleSnack(context, tr("Could not update general settings!")!);
}
_key.currentState.refresh();
_key.currentState!.refresh();
}
}

View File

@ -24,8 +24,8 @@ class _NotificationsSettingsScreenState
extends State<NotificationsSettingsScreen> {
final key = GlobalKey<AsyncScreenWidgetState>();
NotificationsSettings _settings;
PushNotificationsStatus _pushNotificationsStatus;
late NotificationsSettings _settings;
PushNotificationsStatus? _pushNotificationsStatus;
Future<void> _loadSettings() async {
_settings = await SettingsHelper.getNotificationsSettings();
@ -37,7 +37,7 @@ class _NotificationsSettingsScreenState
key: key,
onReload: _loadSettings,
onBuild: _buildScreen,
errorMessage: tr("Failed to load notifications settings!"),
errorMessage: tr("Failed to load notifications settings!")!,
);
Widget _buildScreen() => SettingsList(sections: [
@ -81,7 +81,7 @@ class _NotificationsSettingsScreenState
setState(() {});
} catch (e, s) {
logError(e, s);
snack(context, tr("Failed to update settings!"));
snack(context, tr("Failed to update settings!")!);
}
}
}