1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 04:49:21 +00:00

Fix a few notices

This commit is contained in:
Pierre HUBERT 2022-03-11 17:09:37 +01:00
parent 0f9a59b4a7
commit 41446f0e5b
22 changed files with 36 additions and 139 deletions

View File

@ -58,22 +58,13 @@ class Post implements LikeElement {
required this.access, required this.access,
required this.comments, required this.comments,
required this.survey}) required this.survey})
: assert(id != null), : assert(userPageID != 0 || groupID != 0),
assert(userID != null),
assert(userPageID != 0 || groupID != 0),
assert(timeSent != null),
assert(kind != PostKind.TEXT || content != null),
assert(visibilityLevel != null),
assert(kind != null),
assert(kind != PostKind.COUNTDOWN || timeEnd != null), assert(kind != PostKind.COUNTDOWN || timeEnd != null),
assert(kind != PostKind.SURVEY || survey != null), assert(kind != PostKind.SURVEY || survey != null);
assert(likes != null),
assert(userLike != null),
assert(access != null);
bool get isGroupPost => groupID != null && groupID! > 0; bool get isGroupPost => groupID != null && groupID! > 0;
bool get hasContent => content != null && !content.isNull; bool get hasContent => !content.isNull && !content.isEmpty;
bool get hasComments => comments != null; bool get hasComments => comments != null;

View File

@ -1,5 +1,3 @@
/// Check password reset token result /// Check password reset token result
/// ///
/// @author Pierre Hubert /// @author Pierre Hubert
@ -13,7 +11,5 @@ class ResCheckPasswordToken {
required this.firstName, required this.firstName,
required this.lastName, required this.lastName,
required this.email, required this.email,
}) : assert(firstName != null), });
assert(lastName != null),
assert(email != null);
} }

View File

@ -1,5 +1,3 @@
/// Single search result /// Single search result
/// ///
/// @author Pierre Hubert /// @author Pierre Hubert
@ -13,6 +11,5 @@ class SearchResult {
SearchResult({ SearchResult({
required this.id, required this.id,
required this.kind, required this.kind,
}) : assert(id != null), });
assert(kind != null);
} }

View File

@ -1,5 +1,3 @@
/// Security settings of the user /// Security settings of the user
/// ///
/// @author Pierre HUBERT /// @author Pierre HUBERT
@ -15,8 +13,5 @@ class SecuritySettings {
required this.securityAnswer1, required this.securityAnswer1,
required this.securityQuestion2, required this.securityQuestion2,
required this.securityAnswer2, required this.securityAnswer2,
}) : assert(securityQuestion1 != null), });
assert(securityAnswer1 != null),
assert(securityQuestion2 != null),
assert(securityAnswer2 != null);
} }

View File

@ -35,14 +35,7 @@ class PasswordPolicy {
required this.minNumberDigits, required this.minNumberDigits,
required this.minNumberSpecialCharacters, required this.minNumberSpecialCharacters,
required this.minCategoriesPresence, required this.minCategoriesPresence,
}) : assert(allowMailInPassword != null), });
assert(allowNameInPassword != null),
assert(minPasswordLength != null),
assert(minNumberUpperCaseLetters != null),
assert(minNumberLowerCaseLetters != null),
assert(minNumberDigits != null),
assert(minNumberSpecialCharacters != null),
assert(minCategoriesPresence != null);
} }
class ServerDataConservationPolicy { class ServerDataConservationPolicy {
@ -60,12 +53,7 @@ class ServerDataConservationPolicy {
required this.minPostsLifetime, required this.minPostsLifetime,
required this.minConversationMessagesLifetime, required this.minConversationMessagesLifetime,
required this.minLikesLifetime, required this.minLikesLifetime,
}) : assert(minInactiveAccountLifetime != null), });
assert(minNotificationLifetime != null),
assert(minCommentsLifetime != null),
assert(minPostsLifetime != null),
assert(minConversationMessagesLifetime != null),
assert(minLikesLifetime != null);
} }
class ConversationsPolicy { class ConversationsPolicy {
@ -97,19 +85,7 @@ class ConversationsPolicy {
required this.maxThumbnailHeight, required this.maxThumbnailHeight,
required this.maxLogoWidth, required this.maxLogoWidth,
required this.maxLogoHeight, required this.maxLogoHeight,
}) : assert(maxConversationNameLen != null), });
assert(minMessageLen != null),
assert(maxMessageLen != null),
assert(allowedFilesType != null),
assert(filesMaxSize != null),
assert(writingEventInterval != null),
assert(writingEventLifetime != null),
assert(maxMessageImageWidth != null),
assert(maxMessageImageHeight != null),
assert(maxThumbnailWidth != null),
assert(maxThumbnailHeight != null),
assert(maxLogoWidth != null),
assert(maxLogoHeight != null);
} }
class AccountInformationPolicy { class AccountInformationPolicy {
@ -125,11 +101,7 @@ class AccountInformationPolicy {
required this.minLastNameLength, required this.minLastNameLength,
required this.maxLastNameLength, required this.maxLastNameLength,
required this.maxLocationLength, required this.maxLocationLength,
}) : assert(minFirstNameLength != null), });
assert(maxFirstNameLength != null),
assert(minLastNameLength != null),
assert(maxLastNameLength != null),
assert(maxLocationLength != null);
} }
enum BannerNature { Information, Warning, Success } enum BannerNature { Information, Warning, Success }
@ -161,9 +133,7 @@ class Banner {
required this.nature, required this.nature,
required this.message, required this.message,
required this.link, required this.link,
}) : assert(enabled != null), });
assert(nature != null),
assert(message != null);
bool get visible => enabled && (expire == null || expire! > time()); bool get visible => enabled && (expire == null || expire! > time());
} }
@ -195,15 +165,5 @@ class ServerConfig {
required this.dataConservationPolicy, required this.dataConservationPolicy,
required this.conversationsPolicy, required this.conversationsPolicy,
required this.accountInformationPolicy, required this.accountInformationPolicy,
}) : assert(minSupportedMobileVersion != null), });
assert(termsURL != null),
assert(privacyPolicyURL != null),
assert(contactEmail != null),
assert(playStoreURL != null),
assert(androidDirectDownloadURL != null),
assert(notificationsPolicy != null),
assert(passwordPolicy != null),
assert(dataConservationPolicy != null),
assert(conversationsPolicy != null),
assert(accountInformationPolicy != null);
} }

View File

@ -1,5 +1,3 @@
/// Single survey choice /// Single survey choice
/// ///
/// @author Pierre HUBERT /// @author Pierre HUBERT
@ -13,7 +11,5 @@ class SurveyChoice {
required this.id, required this.id,
required this.name, required this.name,
required this.responses, required this.responses,
}) : assert(id != null), });
assert(name != null),
assert(responses != null);
} }

View File

@ -12,6 +12,5 @@ class UnreadConversation {
const UnreadConversation({ const UnreadConversation({
required this.conv, required this.conv,
required this.message, required this.message,
}) : assert(conv != null), });
assert(message != null);
} }

View File

@ -13,9 +13,7 @@ class WsMessage {
required this.id, required this.id,
required this.title, required this.title,
required this.data, required this.data,
}) : assert(id != null), }) : assert(title.length > 0);
assert(title != null),
assert(title.length > 0);
/// Construct a message from a JSON document (messages coming from the server) /// Construct a message from a JSON document (messages coming from the server)
static WsMessage fromJSON(final Map<dynamic, dynamic> m) { static WsMessage fromJSON(final Map<dynamic, dynamic> m) {
@ -23,12 +21,11 @@ class WsMessage {
} }
/// Turn a message into a JSON object to send it to the API /// Turn a message into a JSON object to send it to the API
String toJSON() => String toJSON() => jsonEncode({
jsonEncode({
"id": id, "id": id,
"title": title, "title": title,
"data": data, "data": data,
}); });
bool get hasId => this.id != null && this.id.isNotEmpty; bool get hasId => this.id.isNotEmpty;
} }

View File

@ -11,9 +11,7 @@ Future<void> alert(BuildContext context, String? msg) async {
class _AlertDialog extends StatelessWidget { class _AlertDialog extends StatelessWidget {
final String msg; final String msg;
const _AlertDialog({Key? key, required this.msg}) const _AlertDialog({Key? key, required this.msg}) : super(key: key);
: assert(msg != null),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -19,8 +19,7 @@ class _AudioPlayerDialog extends StatefulWidget {
const _AudioPlayerDialog({ const _AudioPlayerDialog({
Key? key, Key? key,
required this.url, required this.url,
}) : assert(url != null), }) : super(key: key);
super(key: key);
@override @override
__AudioPlayerDialogState createState() => __AudioPlayerDialogState(); __AudioPlayerDialogState createState() => __AudioPlayerDialogState();

View File

@ -12,8 +12,6 @@ Future<String?> showInputNewPassword({
required BuildContext context, required BuildContext context,
required UserInfoForPassword userInfo, required UserInfoForPassword userInfo,
}) async { }) async {
assert(context != null);
assert(userInfo != null);
return await showDialog( return await showDialog(
context: context, context: context,
builder: (c) => _InputNewPasswordDialog( builder: (c) => _InputNewPasswordDialog(
@ -27,8 +25,7 @@ class _InputNewPasswordDialog extends StatefulWidget {
const _InputNewPasswordDialog({ const _InputNewPasswordDialog({
Key? key, Key? key,
required this.userInfo, required this.userInfo,
}) : assert(userInfo != null), }) : super(key: key);
super(key: key);
@override @override
__InputNewPasswordDialogState createState() => __InputNewPasswordDialogState createState() =>
@ -45,7 +42,8 @@ class __InputNewPasswordDialogState extends State<_InputNewPasswordDialog> {
bool get _input1Valid => bool get _input1Valid =>
_controller1.currentState != null && _controller1.currentState!.valid; _controller1.currentState != null && _controller1.currentState!.valid;
bool get _input2Valid => _controller1.currentState!.value == _controller2.text; bool get _input2Valid =>
_controller1.currentState!.value == _controller2.text;
bool get _isValid => _input1Valid && _input2Valid; bool get _isValid => _input1Valid && _input2Valid;

View File

@ -51,9 +51,7 @@ class _MultiChoicesEntryDialog<T> extends StatefulWidget {
required this.title, required this.title,
required this.defaultChoice, required this.defaultChoice,
required this.choices, required this.choices,
}) : assert(title != null), }) : assert(defaultChoice != null),
assert(defaultChoice != null),
assert(choices != null),
super(key: key); super(key: key);
@override @override

View File

@ -39,10 +39,7 @@ class _PickFileOption {
required this.label, required this.label,
required this.icon, required this.icon,
required this.canEnable, required this.canEnable,
}) : assert(value != null), });
assert(label != null),
assert(icon != null),
assert(canEnable != null);
} }
List<_PickFileOption> get _optionsList => [ List<_PickFileOption> get _optionsList => [
@ -94,8 +91,6 @@ Future<BytesFile?> showPickFileDialog({
int? imageMaxHeight, int? imageMaxHeight,
CropAspectRatio? aspectRatio, CropAspectRatio? aspectRatio,
}) async { }) async {
assert(allowedMimeTypes != null);
// Get the list of allowed extension // Get the list of allowed extension
final allowedExtensions = <String>[]; final allowedExtensions = <String>[];
for (var mime in allowedExtensions) { for (var mime in allowedExtensions) {
@ -196,9 +191,7 @@ class _BottomSheetPickOption extends StatelessWidget {
const _BottomSheetPickOption( const _BottomSheetPickOption(
{Key? key, required this.options, required this.onOptionSelected}) {Key? key, required this.options, required this.onOptionSelected})
: assert(options != null), : super(key: key);
assert(onOptionSelected != null),
super(key: key);
@override @override
Widget build(BuildContext context) => Container( Widget build(BuildContext context) => Container(

View File

@ -266,9 +266,7 @@ class _RecordAction extends StatelessWidget {
required this.icon, required this.icon,
required this.onTap, required this.onTap,
this.color, this.color,
}) : assert(visible != null), }) : super(key: key);
assert(icon != null),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -287,9 +285,7 @@ class _ActionButton extends StatelessWidget {
required this.visible, required this.visible,
required this.text, required this.text,
this.onPressed, this.onPressed,
}) : assert(visible != null), }) : super(key: key);
assert(text != null),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -27,12 +27,7 @@ class SingleInputDialog extends StatefulWidget {
this.canBeEmpty = false, this.canBeEmpty = false,
this.maxLines = 1, this.maxLines = 1,
this.maxLength, this.maxLength,
}) : assert(title != null), }) : super(key: key);
assert(label != null),
assert(checkInput != null),
assert(errorMessage != null),
assert(maxLines != null),
super(key: key);
@override @override
__InputURLDialogState createState() => __InputURLDialogState(); __InputURLDialogState createState() => __InputURLDialogState();

View File

@ -18,11 +18,6 @@ Future<String?> showVirtualDirectoryDialog({
required int id, required int id,
required VirtualDirectoryTargetType type, required VirtualDirectoryTargetType type,
}) async { }) async {
assert(context != null);
assert(initialDirectory != null);
assert(id != null);
assert(type != null);
return await showDialog<String>( return await showDialog<String>(
context: context, context: context,
builder: (c) => _VirtualDirectoryPicker( builder: (c) => _VirtualDirectoryPicker(
@ -39,10 +34,7 @@ class _VirtualDirectoryPicker extends StatefulWidget {
required this.initialDirectory, required this.initialDirectory,
required this.id, required this.id,
required this.type, required this.type,
}) : assert(initialDirectory != null), }) : super(key: key);
assert(id != null),
assert(type != null),
super(key: key);
@override @override
__VirtualDirectoryPickerState createState() => __VirtualDirectoryPickerState createState() =>

View File

@ -246,9 +246,7 @@ class _ResetPasswordBodyState extends SafeState<_ResetPasswordBody> {
class _Spacer extends StatelessWidget { class _Spacer extends StatelessWidget {
final bool visible; final bool visible;
const _Spacer({Key? key, this.visible = true}) const _Spacer({Key? key, this.visible = true}) : super(key: key);
: assert(visible != null),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -50,8 +50,9 @@ abstract class MainController extends State<MainRoute> {
int get numberOfPages => _pagesStack.length; int get numberOfPages => _pagesStack.length;
/// Get current instance of Home controller /// Get current instance of Home controller
///
/// A future implementation might need context again, that is why it is required
static MainController? of(BuildContext context) { static MainController? of(BuildContext context) {
assert(context != null); // A future implementation might need context again
return mainControllerKey.currentState; return mainControllerKey.currentState;
} }

View File

@ -126,7 +126,7 @@ class PushNotificationsConfigurationWidgetState
available: srvConfig!.notificationsPolicy.hasFirebase, available: srvConfig!.notificationsPolicy.hasFirebase,
onChanged: (s) { onChanged: (s) {
setState(() => currStatus = s); setState(() => currStatus = s);
if (widget.onChanged != null) widget.onChanged(); widget.onChanged();
}, },
), ),
SizedBox(height: 5), SizedBox(height: 5),

View File

@ -129,8 +129,7 @@ class _NewCustomEmojiDialog extends StatefulWidget {
const _NewCustomEmojiDialog({ const _NewCustomEmojiDialog({
Key? key, Key? key,
required this.currentList, required this.currentList,
}) : assert(currentList != null), }) : super(key: key);
super(key: key);
@override @override
_NewCustomEmojiDialogState createState() => _NewCustomEmojiDialogState(); _NewCustomEmojiDialogState createState() => _NewCustomEmojiDialogState();

View File

@ -35,8 +35,7 @@ class GroupSettingsScreen extends StatefulWidget {
final int groupID; final int groupID;
const GroupSettingsScreen({Key? key, required this.groupID}) const GroupSettingsScreen({Key? key, required this.groupID})
: assert(groupID != null), : super(key: key);
super(key: key);
@override @override
_GroupSettingsScreenState createState() => _GroupSettingsScreenState(); _GroupSettingsScreenState createState() => _GroupSettingsScreenState();

View File

@ -8,7 +8,7 @@ class MenuTile extends StatelessWidget {
final String title; final String title;
final GestureTapCallback? onTap; final GestureTapCallback? onTap;
const MenuTile({required this.title, this.onTap}) : assert(title != null); const MenuTile({required this.title, this.onTap});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {