diff --git a/lib/core/data/dbo/app_theme_dbo.dart b/lib/core/data/dbo/app_theme_dbo.dart index 53b17714..6c2b09f3 100644 --- a/lib/core/data/dbo/app_theme_dbo.dart +++ b/lib/core/data/dbo/app_theme_dbo.dart @@ -26,9 +26,7 @@ enum AppThemeDBO { case AppThemeEntity.system: dbo = AppThemeDBO.system; break; - default: - return AppThemeDBO.system; - } + } return dbo; } } diff --git a/lib/core/domain/entity/app_theme_entity.dart b/lib/core/domain/entity/app_theme_entity.dart index a13e9caf..df6ac23b 100644 --- a/lib/core/domain/entity/app_theme_entity.dart +++ b/lib/core/domain/entity/app_theme_entity.dart @@ -18,9 +18,7 @@ enum AppThemeEntity { case AppThemeDBO.system: entity = AppThemeEntity.system; break; - default: - return AppThemeEntity.system; - } + } return entity; } diff --git a/lib/core/presentation/widgets/activity_card.dart b/lib/core/presentation/widgets/activity_card.dart index 602058e8..4a5a1f8e 100644 --- a/lib/core/presentation/widgets/activity_card.dart +++ b/lib/core/presentation/widgets/activity_card.dart @@ -44,7 +44,7 @@ class ActivityCard extends StatelessWidget { color: Theme.of(context) .colorScheme .tertiaryContainer - .withOpacity(0.8), + .withValues(alpha: 0.8), borderRadius: BorderRadius.circular(12)), child: Text( "🔥${activityEntity.burnedKcal.toInt()} kcal", @@ -75,7 +75,7 @@ class ActivityCard extends StatelessWidget { child: Text( activityEntity.physicalActivityEntity.getName(context), style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), maxLines: 1, overflow: TextOverflow.ellipsis, ), @@ -87,8 +87,7 @@ class ActivityCard extends StatelessWidget { style: Theme.of(context).textTheme.bodySmall?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.8)), + .onSurface.withValues(alpha: 0.8)), maxLines: 1, )) ], diff --git a/lib/core/presentation/widgets/activity_vertial_list.dart b/lib/core/presentation/widgets/activity_vertial_list.dart index 02e69fa6..000825a2 100644 --- a/lib/core/presentation/widgets/activity_vertial_list.dart +++ b/lib/core/presentation/widgets/activity_vertial_list.dart @@ -28,12 +28,12 @@ class ActivityVerticalList extends StatelessWidget { child: Row( children: [ Icon(UserActivityEntity.getIconData(), - size: 24, color: Theme.of(context).colorScheme.onBackground), + size: 24, color: Theme.of(context).colorScheme.onSurface), const SizedBox(width: 4.0), Text( title, style: Theme.of(context).textTheme.titleLarge?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), ), ], ), diff --git a/lib/core/presentation/widgets/add_item_bottom_sheet.dart b/lib/core/presentation/widgets/add_item_bottom_sheet.dart index 5037d93e..f20d729b 100644 --- a/lib/core/presentation/widgets/add_item_bottom_sheet.dart +++ b/lib/core/presentation/widgets/add_item_bottom_sheet.dart @@ -39,7 +39,7 @@ class AddItemBottomSheet extends StatelessWidget { S.of(context).activityExample, style: Theme.of(context).textTheme.titleMedium?.copyWith( color: - Theme.of(context).colorScheme.onSurface.withOpacity(0.7)), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7)), ), // ignore: sized_box_for_whitespace leading: Container( @@ -65,7 +65,7 @@ class AddItemBottomSheet extends StatelessWidget { S.of(context).breakfastExample, style: Theme.of(context).textTheme.titleMedium?.copyWith( color: - Theme.of(context).colorScheme.onSurface.withOpacity(0.7)), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7)), ), // ignore: sized_box_for_whitespace leading: Container( @@ -87,7 +87,7 @@ class AddItemBottomSheet extends StatelessWidget { S.of(context).lunchExample, style: Theme.of(context).textTheme.titleMedium?.copyWith( color: - Theme.of(context).colorScheme.onSurface.withOpacity(0.7)), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7)), ), // ignore: sized_box_for_whitespace leading: Container( @@ -109,7 +109,7 @@ class AddItemBottomSheet extends StatelessWidget { S.of(context).dinnerExample, style: Theme.of(context).textTheme.titleMedium?.copyWith( color: - Theme.of(context).colorScheme.onSurface.withOpacity(0.7)), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7)), ), // ignore: sized_box_for_whitespace leading: Container( @@ -131,7 +131,7 @@ class AddItemBottomSheet extends StatelessWidget { S.of(context).snackExample, style: Theme.of(context).textTheme.titleMedium?.copyWith( color: - Theme.of(context).colorScheme.onSurface.withOpacity(0.7)), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7)), ), // ignore: sized_box_for_whitespace leading: Container( diff --git a/lib/core/presentation/widgets/app_banner_version.dart b/lib/core/presentation/widgets/app_banner_version.dart index 0f3170f0..d4410911 100644 --- a/lib/core/presentation/widgets/app_banner_version.dart +++ b/lib/core/presentation/widgets/app_banner_version.dart @@ -14,13 +14,13 @@ class AppBannerVersion extends StatelessWidget { const SizedBox(height: 70, child: DynamicOntLogo()), Text(S.of(context).appTitle, style: Theme.of(context).textTheme.headlineSmall?.copyWith( - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, fontWeight: FontWeight.w600)), Text( S.of(context).appVersionName(versionNumber), style: Theme.of(context).textTheme.titleMedium?.copyWith( color: - Theme.of(context).colorScheme.onBackground.withOpacity(0.7)), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7)), ) ], ); diff --git a/lib/core/presentation/widgets/dynamic_ont_logo.dart b/lib/core/presentation/widgets/dynamic_ont_logo.dart index 7db41118..c50fbf22 100644 --- a/lib/core/presentation/widgets/dynamic_ont_logo.dart +++ b/lib/core/presentation/widgets/dynamic_ont_logo.dart @@ -22,7 +22,7 @@ class DynamicOntLogo extends StatelessWidget { svgString = svgString.replaceAll(_circleColor, Theme.of(context).colorScheme.primaryContainer.toHex()); svgString = svgString.replaceAll( - _spoonColor, Theme.of(context).colorScheme.onBackground.toHex()); + _spoonColor, Theme.of(context).colorScheme.onSurface.toHex()); return SvgPicture.string(svgString); } else if (snapshot.connectionState == ConnectionState.waiting) { return const SizedBox(); diff --git a/lib/core/presentation/widgets/home_appbar.dart b/lib/core/presentation/widgets/home_appbar.dart index 5e541f60..84963592 100644 --- a/lib/core/presentation/widgets/home_appbar.dart +++ b/lib/core/presentation/widgets/home_appbar.dart @@ -17,13 +17,13 @@ class HomeAppbar extends StatelessWidget implements PreferredSizeWidget { text: TextSpan( text: S.of(context).appTitle, style: Theme.of(context).textTheme.titleLarge?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), children: [ TextSpan( text: ' ${S.of(context).betaVersionName}', style: TextStyle( fontWeight: FontWeight.w500, - color: Theme.of(context).colorScheme.onBackground)), + color: Theme.of(context).colorScheme.onSurface)), ], ), maxLines: 1, @@ -35,7 +35,7 @@ class HomeAppbar extends StatelessWidget implements PreferredSizeWidget { actions: [ IconButton( icon: Icon(Icons.settings_outlined, - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), tooltip: S.of(context).settingsLabel, onPressed: () { Navigator.of(context).pushNamed(NavigationOptions.settingsRoute); diff --git a/lib/core/presentation/widgets/intake_card.dart b/lib/core/presentation/widgets/intake_card.dart index 0df2dbd6..5630855e 100644 --- a/lib/core/presentation/widgets/intake_card.dart +++ b/lib/core/presentation/widgets/intake_card.dart @@ -65,8 +65,7 @@ class IntakeCard extends StatelessWidget { decoration: BoxDecoration( color: Theme.of(context) .colorScheme - .secondaryContainer - .withOpacity(0.5), + .secondaryContainer.withValues(alpha: 0.5), ), ), Container( @@ -75,8 +74,7 @@ class IntakeCard extends StatelessWidget { decoration: BoxDecoration( color: Theme.of(context) .colorScheme - .tertiaryContainer - .withOpacity(0.8), + .tertiaryContainer.withValues(alpha: 0.8), borderRadius: BorderRadius.circular(20)), child: Text( '${intake.totalKcal.toInt()} kcal', @@ -116,8 +114,8 @@ class IntakeCard extends StatelessWidget { ?.copyWith( color: Theme.of(context) .colorScheme - .onSecondaryContainer - .withOpacity(0.7)), + .onSecondaryContainer.withValues( + alpha: 0.7)), ), ], )) diff --git a/lib/core/presentation/widgets/placeholder_card.dart b/lib/core/presentation/widgets/placeholder_card.dart index 9670edca..fd2d9e87 100644 --- a/lib/core/presentation/widgets/placeholder_card.dart +++ b/lib/core/presentation/widgets/placeholder_card.dart @@ -35,8 +35,7 @@ class PlaceholderCard extends StatelessWidget { size: 36, color: Theme.of(context) .colorScheme - .onSurface - .withOpacity(0.5)), + .onSurface.withValues(alpha: 0.5)), ), ), ), diff --git a/lib/core/styles/color_schemes.dart b/lib/core/styles/color_schemes.dart index 4eef1df8..973cff6e 100644 --- a/lib/core/styles/color_schemes.dart +++ b/lib/core/styles/color_schemes.dart @@ -22,11 +22,9 @@ const lightColorScheme = ColorScheme( errorContainer: Color(0xFFFFDAD6), onError: Color(0xFFFFFFFF), onErrorContainer: Color(0xFF410002), - background: Color(0xFFFCFDF7), - onBackground: Color(0xFF1A1C19), surface: Color(0xFFFCFDF7), onSurface: Color(0xFF1A1C19), - surfaceVariant: Color(0xFFDDE5D9), + surfaceContainerHighest: Color(0xFFDDE5D9), onSurfaceVariant: Color(0xFF424940), outline: Color(0xFF727970), onInverseSurface: Color(0xFFF0F1EB), @@ -56,11 +54,9 @@ const darkColorScheme = ColorScheme( errorContainer: Color(0xFF93000A), onError: Color(0xFF690005), onErrorContainer: Color(0xFFFFDAD6), - background: Color(0xFF1A1C19), - onBackground: Color(0xFFE2E3DD), surface: Color(0xFF1A1C19), onSurface: Color(0xFFE2E3DD), - surfaceVariant: Color(0xFF424940), + surfaceContainerHighest: Color(0xFF424940), onSurfaceVariant: Color(0xFFC1C9BE), outline: Color(0xFF8B9389), onInverseSurface: Color(0xFF1A1C19), diff --git a/lib/core/utils/extensions.dart b/lib/core/utils/extensions.dart index defb8378..3b31c063 100644 --- a/lib/core/utils/extensions.dart +++ b/lib/core/utils/extensions.dart @@ -64,9 +64,10 @@ extension FormatString on DateTime { extension ColorExtension on Color { /// Converts the color to a hexadecimal string. String toHex() { - return '#${red.toRadixString(16).padLeft(2, '0')}' - '${green.toRadixString(16).padLeft(2, '0')}' - '${blue.toRadixString(16).padLeft(2, '0')}' - '${alpha.toRadixString(16).padLeft(2, '0')}'; // Includes the alpha channel + final red = (r * 255).toInt().toRadixString(16).padLeft(2, '0'); + final green = (g * 255).toInt().toRadixString(16).padLeft(2, '0'); + final blue = (b * 255).toInt().toRadixString(16).padLeft(2, '0'); + + return '#' '$red$green$blue'.toUpperCase(); } } diff --git a/lib/features/activity_detail/activity_detail_screen.dart b/lib/features/activity_detail/activity_detail_screen.dart index 7117c718..e1ff8725 100644 --- a/lib/features/activity_detail/activity_detail_screen.dart +++ b/lib/features/activity_detail/activity_detail_screen.dart @@ -119,7 +119,7 @@ class _ActivityDetailScreenState extends State { ?.copyWith( color: Theme.of(context) .colorScheme - .onBackground)) + .onSurface)) : const SizedBox(), ), ); diff --git a/lib/features/activity_detail/presentation/widget/activity_title_expanded.dart b/lib/features/activity_detail/presentation/widget/activity_title_expanded.dart index 4eead001..1980ee07 100644 --- a/lib/features/activity_detail/presentation/widget/activity_title_expanded.dart +++ b/lib/features/activity_detail/presentation/widget/activity_title_expanded.dart @@ -21,7 +21,7 @@ class ActivityTitleExpanded extends StatelessWidget { TextSpan( text: activity.getName(context), style: Theme.of(context).textTheme.displaySmall?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), children: [ TextSpan( text: ' ${activity.getDescription(context)} ', @@ -31,8 +31,7 @@ class ActivityTitleExpanded extends StatelessWidget { ?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.7)), + .onSurface.withValues(alpha: 0.7)), ) ]), textAlign: TextAlign.center, diff --git a/lib/features/add_activity/presentation/widgets/activity_item_card.dart b/lib/features/add_activity/presentation/widgets/activity_item_card.dart index 7af04a94..5adcbb10 100644 --- a/lib/features/add_activity/presentation/widgets/activity_item_card.dart +++ b/lib/features/add_activity/presentation/widgets/activity_item_card.dart @@ -34,14 +34,14 @@ class ActivityItemCard extends StatelessWidget { title: AutoSizeText( physicalActivityEntity.getName(context), style: Theme.of(context).textTheme.titleLarge?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), maxLines: 1, overflow: TextOverflow.ellipsis, ), subtitle: AutoSizeText( physicalActivityEntity.getDescription(context), style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), maxLines: 3, overflow: TextOverflow.ellipsis, ), diff --git a/lib/features/add_meal/data/dto/fdc_sp/sp_const.dart b/lib/features/add_meal/data/dto/fdc_sp/sp_const.dart index b8a62415..6cffd5ac 100644 --- a/lib/features/add_meal/data/dto/fdc_sp/sp_const.dart +++ b/lib/features/add_meal/data/dto/fdc_sp/sp_const.dart @@ -26,9 +26,7 @@ class SPConst { return fdcFoodDescriptionEn; case SupportedLanguage.de: return fdcFoodDescriptionDe; - default: - return fdcFoodDescriptionEn; - } + } } } diff --git a/lib/features/add_meal/data/dto/fdc_sp/sp_fdc_food_dto.dart b/lib/features/add_meal/data/dto/fdc_sp/sp_fdc_food_dto.dart index 8d80ba76..704ef040 100644 --- a/lib/features/add_meal/data/dto/fdc_sp/sp_fdc_food_dto.dart +++ b/lib/features/add_meal/data/dto/fdc_sp/sp_fdc_food_dto.dart @@ -29,9 +29,7 @@ class SpFdcFoodDTO { return descriptionEn; case SupportedLanguage.de: return descriptionDe; - default: - return descriptionEn; - } + } } get servingSize => portions diff --git a/lib/features/add_meal/data/dto/off/off_product_dto.dart b/lib/features/add_meal/data/dto/off/off_product_dto.dart index 204d1069..841c1b5c 100644 --- a/lib/features/add_meal/data/dto/off/off_product_dto.dart +++ b/lib/features/add_meal/data/dto/off/off_product_dto.dart @@ -40,9 +40,7 @@ class OFFProductDTO { case SupportedLanguage.de: localeName = product_name_de; break; - default: - return product_name_en; - } + } // If local language is not available, return available language if (localeName == null || localeName.isEmpty) { diff --git a/lib/features/add_meal/presentation/widgets/meal_item_card.dart b/lib/features/add_meal/presentation/widgets/meal_item_card.dart index 995042ef..4af3bcee 100644 --- a/lib/features/add_meal/presentation/widgets/meal_item_card.dart +++ b/lib/features/add_meal/presentation/widgets/meal_item_card.dart @@ -8,6 +8,7 @@ import 'package:opennutritracker/core/utils/navigation_options.dart'; import 'package:opennutritracker/features/add_meal/domain/entity/meal_entity.dart'; import 'package:opennutritracker/features/add_meal/presentation/add_meal_type.dart'; import 'package:opennutritracker/features/meal_detail/meal_detail_screen.dart'; + class MealItemCard extends StatelessWidget { final DateTime day; final AddMealType addMealType; @@ -56,7 +57,7 @@ class MealItemCard extends StatelessWidget { TextSpan( text: mealEntity.name ?? "?", style: Theme.of(context).textTheme.titleLarge?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), children: [ TextSpan( text: ' ${mealEntity.brands ?? ""}', @@ -66,8 +67,8 @@ class MealItemCard extends StatelessWidget { ?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.8))) + .onSurface + .withValues(alpha: 0.8))), ]), style: Theme.of(context).textTheme.titleLarge, maxLines: 2, diff --git a/lib/features/diary/presentation/widgets/day_info_widget.dart b/lib/features/diary/presentation/widgets/day_info_widget.dart index b353a4c9..865ff9ea 100644 --- a/lib/features/diary/presentation/widgets/day_info_widget.dart +++ b/lib/features/diary/presentation/widgets/day_info_widget.dart @@ -70,8 +70,7 @@ class DayInfoWidget extends StatelessWidget { style: Theme.of(context).textTheme.bodyMedium?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.7))), + .onSurface.withValues(alpha: 0.7))), ) : const SizedBox(), trackedDay != null @@ -110,8 +109,7 @@ class DayInfoWidget extends StatelessWidget { ?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.7))) + .onSurface.withValues(alpha: 0.7))), ], ), ) diff --git a/lib/features/diary/presentation/widgets/diary_table_calendar.dart b/lib/features/diary/presentation/widgets/diary_table_calendar.dart index ccc2b01f..80d48af8 100644 --- a/lib/features/diary/presentation/widgets/diary_table_calendar.dart +++ b/lib/features/diary/presentation/widgets/diary_table_calendar.dart @@ -44,7 +44,7 @@ class _DiaryTableCalendarState extends State { Theme.of(context).textTheme.bodyMedium ?? const TextStyle(), todayDecoration: BoxDecoration( border: Border.all( - color: Theme.of(context).colorScheme.onBackground, + color: Theme.of(context).colorScheme.onSurface, width: 2.0), shape: BoxShape.circle), selectedTextStyle: Theme.of(context) diff --git a/lib/features/edit_meal/presentation/edit_meal_screen.dart b/lib/features/edit_meal/presentation/edit_meal_screen.dart index f5d9219e..2a8d5d00 100644 --- a/lib/features/edit_meal/presentation/edit_meal_screen.dart +++ b/lib/features/edit_meal/presentation/edit_meal_screen.dart @@ -276,10 +276,6 @@ class _EditMealScreenState extends State { ? _convertToMetric( _mealQuantityTextController.text, _mealEntity.mealUnit ?? "0") : _mealQuantityTextController.text; - final servingQuantity = usesImperialUnits - ? _convertToMetric( - _servingQuantityTextController.text, _mealEntity.mealUnit ?? "0") - : _servingQuantityTextController.text; final newMealEntity = _editMealBloc.createNewMealEntity( _mealEntity, diff --git a/lib/features/home/home_page.dart b/lib/features/home/home_page.dart index cdcd8a1d..0b54320c 100644 --- a/lib/features/home/home_page.dart +++ b/lib/features/home/home_page.dart @@ -183,7 +183,8 @@ class _HomePageState extends State with WidgetsBindingObserver { visible: _isDragging, child: Container( height: 70, - color: Theme.of(context).colorScheme.error.withOpacity(0.3), + color: Theme.of(context).colorScheme.error + ..withValues(alpha: 0.3), child: DragTarget( onAcceptWithDetails: (data) { _confirmDelete(context, data.data); diff --git a/lib/features/home/presentation/widgets/intake_vertical_list.dart b/lib/features/home/presentation/widgets/intake_vertical_list.dart index 27a5a419..1b4464c9 100644 --- a/lib/features/home/presentation/widgets/intake_vertical_list.dart +++ b/lib/features/home/presentation/widgets/intake_vertical_list.dart @@ -65,12 +65,14 @@ class _IntakeVerticalListState extends State { child: Row( children: [ Icon(widget.listIcon, - size: 24, color: Theme.of(context).colorScheme.onBackground), + size: 24, color: Theme.of(context).colorScheme.onSurface), const SizedBox(width: 4.0), Text( widget.title, - style: Theme.of(context).textTheme.titleLarge?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + style: Theme.of(context) + .textTheme + .titleLarge + ?.copyWith(color: Theme.of(context).colorScheme.onSurface), ), const Spacer(), if (totalKcal > 0) @@ -79,8 +81,8 @@ class _IntakeVerticalListState extends State { style: Theme.of(context).textTheme.titleSmall?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.7)), + .onSurface + .withValues(alpha: 0.7)), ), ], ), diff --git a/lib/features/meal_detail/presentation/widgets/meal_detail_nutriments_table.dart b/lib/features/meal_detail/presentation/widgets/meal_detail_nutriments_table.dart index e96a0fae..dfe578c4 100644 --- a/lib/features/meal_detail/presentation/widgets/meal_detail_nutriments_table.dart +++ b/lib/features/meal_detail/presentation/widgets/meal_detail_nutriments_table.dart @@ -28,7 +28,7 @@ class MealDetailNutrimentsTable extends StatelessWidget { defaultVerticalAlignment: TableCellVerticalAlignment.middle, border: TableBorder.all( color: - Theme.of(context).colorScheme.onBackground.withOpacity(0.5)), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.5)), children: [ _getNutrimentsTableRow( "", S.of(context).per100gmlLabel, textStyleBold), diff --git a/lib/features/meal_detail/presentation/widgets/meal_title_expanded.dart b/lib/features/meal_detail/presentation/widgets/meal_title_expanded.dart index 3b06eeb2..e8ad80c2 100644 --- a/lib/features/meal_detail/presentation/widgets/meal_title_expanded.dart +++ b/lib/features/meal_detail/presentation/widgets/meal_title_expanded.dart @@ -24,7 +24,7 @@ class MealTitleExpanded extends StatelessWidget { TextSpan( text: meal.name ?? '', style: Theme.of(context).textTheme.displaySmall?.copyWith( - color: Theme.of(context).colorScheme.onBackground), + color: Theme.of(context).colorScheme.onSurface), children: [ TextSpan( text: ' ${meal.brands ?? ''}', @@ -34,8 +34,8 @@ class MealTitleExpanded extends StatelessWidget { ?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.7))) + .onSurface + .withValues(alpha: 0.7))), ]), textAlign: TextAlign.center, maxLines: 2, @@ -52,8 +52,8 @@ class MealTitleExpanded extends StatelessWidget { ?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.8)), + .onSurface + .withValues(alpha: 0.8)), prefix: ''), ) : const SizedBox(), diff --git a/lib/features/meal_detail/presentation/widgets/off_disclaimer.dart b/lib/features/meal_detail/presentation/widgets/off_disclaimer.dart index 171ed2a9..164af7f3 100644 --- a/lib/features/meal_detail/presentation/widgets/off_disclaimer.dart +++ b/lib/features/meal_detail/presentation/widgets/off_disclaimer.dart @@ -8,7 +8,8 @@ class OffDisclaimer extends StatelessWidget { Widget build(BuildContext context) { return Text(S.of(context).offDisclaimer, style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7), fontStyle: FontStyle.italic) - ); + color: + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7), + fontStyle: FontStyle.italic)); } } diff --git a/lib/features/onboarding/presentation/widgets/onboarding_overview_page_body.dart b/lib/features/onboarding/presentation/widgets/onboarding_overview_page_body.dart index 1961d98e..5a185e06 100644 --- a/lib/features/onboarding/presentation/widgets/onboarding_overview_page_body.dart +++ b/lib/features/onboarding/presentation/widgets/onboarding_overview_page_body.dart @@ -44,8 +44,7 @@ class OnboardingOverviewPageBody extends StatelessWidget { style: Theme.of(context).textTheme.titleMedium?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.6))) + .onSurface.withValues(alpha: 0.6))) ], ), ), @@ -66,8 +65,7 @@ class OnboardingOverviewPageBody extends StatelessWidget { style: Theme.of(context).textTheme.titleMedium?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.6))), + .onSurface.withValues(alpha: 0.6))), const SizedBox(height: 8.0), Text('$fatGoalString g', style: Theme.of(context).textTheme.headlineSmall?.copyWith( @@ -76,8 +74,7 @@ class OnboardingOverviewPageBody extends StatelessWidget { style: Theme.of(context).textTheme.titleMedium?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.6))), + .onSurface.withValues(alpha: 0.6))), const SizedBox(height: 8.0), Text('$proteinGoalString g', style: Theme.of(context).textTheme.headlineSmall?.copyWith( @@ -86,8 +83,7 @@ class OnboardingOverviewPageBody extends StatelessWidget { style: Theme.of(context).textTheme.titleMedium?.copyWith( color: Theme.of(context) .colorScheme - .onBackground - .withOpacity(0.6))), + .onSurface.withValues(alpha: 0.6))), ], ), ), diff --git a/lib/features/profile/presentation/widgets/bmi_overview.dart b/lib/features/profile/presentation/widgets/bmi_overview.dart index 065a2f58..480181fb 100644 --- a/lib/features/profile/presentation/widgets/bmi_overview.dart +++ b/lib/features/profile/presentation/widgets/bmi_overview.dart @@ -59,8 +59,10 @@ class BMIOverview extends StatelessWidget { S.of(context).nutritionalStatusRiskLabel( nutritionalStatus.getRiskStatus(context)), style: Theme.of(context).textTheme.titleMedium?.copyWith( - color: - Theme.of(context).colorScheme.onBackground.withOpacity(0.7)), + color: Theme.of(context) + .colorScheme + .onSurface + .withValues(alpha: 0.7)), ) ], ); @@ -70,19 +72,26 @@ class BMIOverview extends StatelessWidget { Color theme; switch (nutritionalStatus) { case UserNutritionalStatus.underWeight: - theme = Theme.of(context).colorScheme.errorContainer.withOpacity(0.1); + theme = Theme.of(context).colorScheme.errorContainer + ..withValues(alpha: 0.1); break; case UserNutritionalStatus.normalWeight: - theme = Theme.of(context).colorScheme.primaryContainer.withOpacity(0.6); + theme = Theme.of(context) + .colorScheme + .primaryContainer + .withValues(alpha: 0.6); break; case UserNutritionalStatus.preObesity: - theme = Theme.of(context).colorScheme.errorContainer.withOpacity(0.2); + theme = + Theme.of(context).colorScheme.errorContainer.withValues(alpha: 0.2); break; case UserNutritionalStatus.obesityClassI: - theme = Theme.of(context).colorScheme.errorContainer.withOpacity(0.4); + theme = + Theme.of(context).colorScheme.errorContainer.withValues(alpha: 0.4); break; case UserNutritionalStatus.obesityClassII: - theme = Theme.of(context).colorScheme.errorContainer.withOpacity(0.7); + theme = + Theme.of(context).colorScheme.errorContainer.withValues(alpha: 0.7); break; case UserNutritionalStatus.obesityClassIII: theme = Theme.of(context).colorScheme.errorContainer; diff --git a/lib/features/scanner/scanner_screen.dart b/lib/features/scanner/scanner_screen.dart index 25f49016..56760387 100644 --- a/lib/features/scanner/scanner_screen.dart +++ b/lib/features/scanner/scanner_screen.dart @@ -54,10 +54,14 @@ class _ScannerScreenState extends State { body: const Center(child: CircularProgressIndicator())); } else if (state is ScannerLoadedState) { // Push new route after build - Future.microtask(() => Navigator.of(context).pushReplacementNamed( - NavigationOptions.mealDetailRoute, - arguments: MealDetailScreenArguments(state.product, - _intakeTypeEntity, _day, state.usesImperialUnits))); + Future.microtask(() { + if (context.mounted) { + return Navigator.of(context).pushReplacementNamed( + NavigationOptions.mealDetailRoute, + arguments: MealDetailScreenArguments(state.product, + _intakeTypeEntity, _day, state.usesImperialUnits)); + } + }); } else if (state is ScannerFailedState) { return Scaffold( appBar: AppBar(),