diff --git a/lib/app_state.dart b/lib/app_state.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/app_state.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart index 53c0577b..9e74d94e 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart @@ -281,7 +281,10 @@ class _ScheduleProvisionalVisitPageWidgetState extends State(T? value, T defaultValue) => - (value is String && value.isEmpty) || value == null ? defaultValue : value; +T valueOrDefault(T? value, T defaultValue) => (value is String && value.isEmpty) || value == null ? defaultValue : value; void _setTimeagoLocales() { timeago.setLocaleMessages('pt', timeago.PtBrMessages()); @@ -68,8 +66,7 @@ Theme wrapInMaterialDatePickerTheme( required double iconSize, }) { final baseTheme = Theme.of(context); - final dateTimeMaterialStateForegroundColor = - WidgetStateProperty.resolveWith((states) { + final dateTimeMaterialStateForegroundColor = WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.disabled)) { return pickerForegroundColor.withOpacity(0.60); } @@ -82,8 +79,7 @@ Theme wrapInMaterialDatePickerTheme( return null; }); - final dateTimeMaterialStateBackgroundColor = - WidgetStateProperty.resolveWith((states) { + final dateTimeMaterialStateBackgroundColor = WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.selected)) { return selectedDateTimeBackgroundColor; } @@ -152,8 +148,7 @@ Theme wrapInMaterialDatePickerTheme( if (states.contains(WidgetState.hovered)) { return actionButtonForegroundColor.withOpacity(0.04); } - if (states.contains(WidgetState.focused) || - states.contains(WidgetState.pressed)) { + if (states.contains(WidgetState.focused) || states.contains(WidgetState.pressed)) { return actionButtonForegroundColor.withOpacity(0.12); } return null; @@ -252,8 +247,7 @@ Theme wrapInMaterialTimePickerTheme( if (states.contains(WidgetState.hovered)) { return actionButtonForegroundColor.withOpacity(0.04); } - if (states.contains(WidgetState.focused) || - states.contains(WidgetState.pressed)) { + if (states.contains(WidgetState.focused) || states.contains(WidgetState.pressed)) { return actionButtonForegroundColor.withOpacity(0.12); } return null; @@ -264,21 +258,12 @@ Theme wrapInMaterialTimePickerTheme( backgroundColor: pickerBackgroundColor, hourMinuteTextColor: pickerForegroundColor, dialHandColor: selectedDateTimeBackgroundColor, - dialTextColor: WidgetStateColor.resolveWith((states) => - states.contains(WidgetState.selected) - ? selectedDateTimeForegroundColor - : pickerDialForegroundColor), + dialTextColor: WidgetStateColor.resolveWith((states) => states.contains(WidgetState.selected) ? selectedDateTimeForegroundColor : pickerDialForegroundColor), dayPeriodBorderSide: BorderSide( color: pickerForegroundColor, ), - dayPeriodTextColor: WidgetStateColor.resolveWith((states) => - states.contains(WidgetState.selected) - ? selectedDateTimeForegroundColor - : pickerForegroundColor), - dayPeriodColor: WidgetStateColor.resolveWith((states) => - states.contains(WidgetState.selected) - ? selectedDateTimeBackgroundColor - : Colors.transparent), + dayPeriodTextColor: WidgetStateColor.resolveWith((states) => states.contains(WidgetState.selected) ? selectedDateTimeForegroundColor : pickerForegroundColor), + dayPeriodColor: WidgetStateColor.resolveWith((states) => states.contains(WidgetState.selected) ? selectedDateTimeBackgroundColor : Colors.transparent), entryModeIconColor: pickerForegroundColor, ), ), @@ -361,8 +346,7 @@ String formatNumber( break; case FormatType.custom: final hasLocale = locale != null && locale.isNotEmpty; - formattedValue = - NumberFormat(format, hasLocale ? locale : null).format(value); + formattedValue = NumberFormat(format, hasLocale ? locale : null).format(value); } if (formattedValue.isEmpty) { @@ -370,9 +354,7 @@ String formatNumber( } if (currency != null) { - final currencySymbol = currency.isNotEmpty - ? currency - : NumberFormat.simpleCurrency().format(0.0).substring(0, 1); + final currencySymbol = currency.isNotEmpty ? currency : NumberFormat.simpleCurrency().format(0.0).substring(0, 1); formattedValue = '$currencySymbol$formattedValue'; } @@ -430,9 +412,7 @@ dynamic getJsonField( } final value = field.first.value; if (isForList) { - return value is! Iterable - ? [value] - : (value is List ? value : value.toList()); + return value is! Iterable ? [value] : (value is List ? value : value.toList()); } return value; } @@ -453,8 +433,7 @@ bool get isWeb => kIsWeb; const kBreakpointSmall = 479.0; const kBreakpointMedium = 767.0; const kBreakpointLarge = 991.0; -bool isMobileWidth(BuildContext context) => - MediaQuery.sizeOf(context).width < kBreakpointSmall; +bool isMobileWidth(BuildContext context) => MediaQuery.sizeOf(context).width < kBreakpointSmall; bool responsiveVisibility({ required BuildContext context, bool phone = true, @@ -478,8 +457,7 @@ const kTextValidatorUsernameRegex = r'^[a-zA-Z][a-zA-Z0-9_-]{2,16}$'; // https://stackoverflow.com/a/201378 const kTextValidatorEmailRegex = "^(?:[a-zA-Z0-9!#\$%&\'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#\$%&\'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])\$"; -const kTextValidatorWebsiteRegex = - r'(https?:\/\/)?(www\.)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,10}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)|(https?:\/\/)?(www\.)?(?!ww)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,10}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)'; +const kTextValidatorWebsiteRegex = r'(https?:\/\/)?(www\.)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,10}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)|(https?:\/\/)?(www\.)?(?!ww)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,10}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)'; extension FFTextEditingControllerExt on TextEditingController? { String get text => this == null ? '' : this!.text; @@ -487,28 +465,20 @@ extension FFTextEditingControllerExt on TextEditingController? { } extension IterableExt on Iterable { - List sortedList( - {S Function(T)? keyOf, bool desc = false}) { - final sortedAscending = toList() - ..sort(keyOf == null ? null : ((a, b) => keyOf(a).compareTo(keyOf(b)))); + List sortedList({S Function(T)? keyOf, bool desc = false}) { + final sortedAscending = toList()..sort(keyOf == null ? null : ((a, b) => keyOf(a).compareTo(keyOf(b)))); if (desc) { return sortedAscending.reversed.toList(); } return sortedAscending; } - List mapIndexed(S Function(int, T) func) => toList() - .asMap() - .map((index, value) => MapEntry(index, func(index, value))) - .values - .toList(); + List mapIndexed(S Function(int, T) func) => toList().asMap().map((index, value) => MapEntry(index, func(index, value))).values.toList(); } -void setAppLanguage(BuildContext context, String language) => - App.of(context).setLocale(language); +void setAppLanguage(BuildContext context, String language) => App.of(context).setLocale(language); -void setDarkModeSetting(BuildContext context, ThemeMode themeMode) => - App.of(context).setThemeMode(themeMode); +void setDarkModeSetting(BuildContext context, ThemeMode themeMode) => App.of(context).setThemeMode(themeMode); void showSnackbar( BuildContext context, @@ -542,9 +512,7 @@ void showSnackbar( ], ), duration: Duration(seconds: duration), - backgroundColor: error - ? FlutterFlowTheme.of(context).error - : FlutterFlowTheme.of(context).success, + backgroundColor: error ? FlutterFlowTheme.of(context).error : FlutterFlowTheme.of(context).success, behavior: SnackBarBehavior.floating, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30), @@ -553,8 +521,7 @@ void showSnackbar( ); } -void showAlertDialog(BuildContext context, String title, String content, - Future Function() action) { +void showAlertDialog(BuildContext context, String title, String content, Future Function() action) { showDialog( context: context, builder: (context) { @@ -619,10 +586,7 @@ void showAlertDialog(BuildContext context, String title, String content, } extension FFStringExt on String { - String maybeHandleOverflow({int? maxChars, String replacement = ''}) => - maxChars != null && length > maxChars - ? replaceRange(maxChars, null, replacement) - : this; + String maybeHandleOverflow({int? maxChars, String replacement = ''}) => maxChars != null && length > maxChars ? replaceRange(maxChars, null, replacement) : this; } extension ListFilterExt on Iterable { @@ -631,40 +595,26 @@ extension ListFilterExt on Iterable { extension MapFilterExtensions on Map { Map get withoutNulls => Map.fromEntries( - entries - .where((e) => e.value != null) - .map((e) => MapEntry(e.key, e.value as T)), + entries.where((e) => e.value != null).map((e) => MapEntry(e.key, e.value as T)), ); } extension MapListContainsExt on List { - bool containsMap(dynamic map) => map is Map - ? any((e) => e is Map && const DeepCollectionEquality().equals(e, map)) - : contains(map); + bool containsMap(dynamic map) => map is Map ? any((e) => e is Map && const DeepCollectionEquality().equals(e, map)) : contains(map); } extension ListDivideExt on Iterable { Iterable> get enumerate => toList().asMap().entries; - List divide(Widget t, {bool Function(int)? filterFn}) => isEmpty - ? [] - : (enumerate - .map((e) => [e.value, if (filterFn == null || filterFn(e.key)) t]) - .expand((i) => i) - .toList() - ..removeLast()); + List divide(Widget t, {bool Function(int)? filterFn}) => isEmpty ? [] : (enumerate.map((e) => [e.value, if (filterFn == null || filterFn(e.key)) t]).expand((i) => i).toList()..removeLast()); List around(Widget t) => addToStart(t).addToEnd(t); - List addToStart(Widget t) => - enumerate.map((e) => e.value).toList()..insert(0, t); + List addToStart(Widget t) => enumerate.map((e) => e.value).toList()..insert(0, t); - List addToEnd(Widget t) => - enumerate.map((e) => e.value).toList()..add(t); + List addToEnd(Widget t) => enumerate.map((e) => e.value).toList()..add(t); - List paddingTopEach(double val) => - map((w) => Padding(padding: EdgeInsets.only(top: val), child: w)) - .toList(); + List paddingTopEach(double val) => map((w) => Padding(padding: EdgeInsets.only(top: val), child: w)).toList(); } extension StatefulWidgetExtensions on State {