From b915c764efe4bae459d700d78b7a2f83e0e80d3c Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 19 May 2021 11:50:43 +0200 Subject: [PATCH] Don't check AppLocalizations for null values This is not needed in flutter 2.2 anymore --- README.md | 4 +- lib/helpers/ui.dart | 4 +- lib/screens/auth_screen.dart | 38 ++++++------- lib/screens/dashboard.dart | 4 +- lib/screens/gallery_screen.dart | 4 +- lib/screens/home_tabs_screen.dart | 10 ++-- lib/screens/nutritional_plan_screen.dart | 6 +- lib/screens/nutritional_plans_screen.dart | 4 +- lib/screens/weight_screen.dart | 4 +- lib/screens/workout_plan_screen.dart | 10 ++-- lib/screens/workout_plans_screen.dart | 4 +- lib/widgets/app_drawer.dart | 2 +- lib/widgets/core/about.dart | 20 +++---- lib/widgets/core/app_bar.dart | 4 +- lib/widgets/dashboard/calendar.dart | 10 ++-- lib/widgets/dashboard/widgets.dart | 36 ++++++------ lib/widgets/exercises/exercises.dart | 10 ++-- lib/widgets/gallery/forms.dart | 14 ++--- lib/widgets/gallery/overview.dart | 2 +- lib/widgets/nutrition/charts.dart | 10 ++-- lib/widgets/nutrition/forms.dart | 18 +++--- lib/widgets/nutrition/meal.dart | 34 +++++------ .../nutrition/nutritional_plan_detail.dart | 50 ++++++++--------- .../nutrition/nutritional_plans_list.dart | 6 +- lib/widgets/weight/entries_list.dart | 4 +- lib/widgets/weight/forms.dart | 10 ++-- lib/widgets/workouts/charts.dart | 2 +- lib/widgets/workouts/day.dart | 8 +-- lib/widgets/workouts/forms.dart | 56 +++++++++---------- lib/widgets/workouts/gym_mode.dart | 32 +++++------ lib/widgets/workouts/workout_logs.dart | 8 +-- lib/widgets/workouts/workout_plan_detail.dart | 6 +- lib/widgets/workouts/workout_plans_list.dart | 6 +- pubspec.lock | 12 ++-- 34 files changed, 226 insertions(+), 226 deletions(-) diff --git a/README.md b/README.md index 5704a810d..20e0e7a22 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ Alternatively, you can use one of our test servers, just ask us for access. ### 2 Install Flutter, all its dependencies and create a new virtual device: - +. + +The app currently uses flutter 2.2 ### 3 Create a new file ``wger.properties`` in ``android/fastlane/envfiles``: diff --git a/lib/helpers/ui.dart b/lib/helpers/ui.dart index 4c4a214b5..b115e6ea8 100644 --- a/lib/helpers/ui.dart +++ b/lib/helpers/ui.dart @@ -30,7 +30,7 @@ void showErrorDialog(dynamic exception, BuildContext context) { showDialog( context: context, builder: (ctx) => AlertDialog( - title: Text(AppLocalizations.of(context)!.anErrorOccurred), + title: Text(AppLocalizations.of(context).anErrorOccurred), content: Text(exception.toString()), actions: [ TextButton( @@ -67,7 +67,7 @@ void showHttpExceptionErrorDialog(WgerHttpException exception, BuildContext cont showDialog( context: context, builder: (ctx) => AlertDialog( - title: Text(AppLocalizations.of(context)!.anErrorOccurred), + title: Text(AppLocalizations.of(context).anErrorOccurred), content: Container( child: Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/screens/auth_screen.dart b/lib/screens/auth_screen.dart index b7214530c..f8fc9148d 100644 --- a/lib/screens/auth_screen.dart +++ b/lib/screens/auth_screen.dart @@ -182,14 +182,14 @@ class _AuthCardState extends State { children: [ TextFormField( key: Key('inputUsername'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.username), + decoration: InputDecoration(labelText: AppLocalizations.of(context).username), autofillHints: [AutofillHints.username], controller: _usernameController, textInputAction: TextInputAction.next, keyboardType: TextInputType.emailAddress, validator: (value) { if (value!.isEmpty) { - return AppLocalizations.of(context)!.invalidUsername; + return AppLocalizations.of(context).invalidUsername; } return null; }, @@ -200,7 +200,7 @@ class _AuthCardState extends State { if (_authMode == AuthMode.Signup) TextFormField( key: Key('inputEmail'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.email), + decoration: InputDecoration(labelText: AppLocalizations.of(context).email), autofillHints: [AutofillHints.email], controller: _emailController, keyboardType: TextInputType.emailAddress, @@ -209,7 +209,7 @@ class _AuthCardState extends State { // Email is not required validator: (value) { if (value!.isNotEmpty && !value.contains('@')) { - return AppLocalizations.of(context)!.invalidEmail; + return AppLocalizations.of(context).invalidEmail; } return null; }, @@ -219,14 +219,14 @@ class _AuthCardState extends State { ), TextFormField( key: Key('inputPassword'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.password), + decoration: InputDecoration(labelText: AppLocalizations.of(context).password), autofillHints: [AutofillHints.password], obscureText: true, controller: _passwordController, textInputAction: TextInputAction.next, validator: (value) { if (value!.isEmpty || value.length < 8) { - return AppLocalizations.of(context)!.passwordTooShort; + return AppLocalizations.of(context).passwordTooShort; } return null; }, @@ -238,14 +238,14 @@ class _AuthCardState extends State { TextFormField( key: Key('inputPassword2'), decoration: - InputDecoration(labelText: AppLocalizations.of(context)!.confirmPassword), + InputDecoration(labelText: AppLocalizations.of(context).confirmPassword), controller: _password2Controller, enabled: _authMode == AuthMode.Signup, obscureText: true, validator: _authMode == AuthMode.Signup ? (value) { if (value != _passwordController.text) { - return AppLocalizations.of(context)!.passwordsDontMatch; + return AppLocalizations.of(context).passwordsDontMatch; } return null; } @@ -262,17 +262,17 @@ class _AuthCardState extends State { child: TextFormField( key: Key('inputServer'), decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.customServerUrl, - helperText: AppLocalizations.of(context)!.customServerHint, + labelText: AppLocalizations.of(context).customServerUrl, + helperText: AppLocalizations.of(context).customServerHint, helperMaxLines: 4), controller: _serverUrlController, validator: (value) { if (Uri.tryParse(value!) == null) { - return AppLocalizations.of(context)!.invalidUrl; + return AppLocalizations.of(context).invalidUrl; } if (value.isEmpty || !value.contains('http')) { - return AppLocalizations.of(context)!.invalidUrl; + return AppLocalizations.of(context).invalidUrl; } return null; }, @@ -293,7 +293,7 @@ class _AuthCardState extends State { _serverUrlController.text = DEFAULT_SERVER; }, ), - Text(AppLocalizations.of(context)!.reset) + Text(AppLocalizations.of(context).reset) ], ), ], @@ -308,8 +308,8 @@ class _AuthCardState extends State { ElevatedButton( key: Key('actionButton'), child: Text(_authMode == AuthMode.Login - ? AppLocalizations.of(context)!.login - : AppLocalizations.of(context)!.register), + ? AppLocalizations.of(context).login + : AppLocalizations.of(context).register), onPressed: () { return _submit(context); }, @@ -318,15 +318,15 @@ class _AuthCardState extends State { key: Key('toggleActionButton'), child: Text( _authMode == AuthMode.Login - ? AppLocalizations.of(context)!.registerInstead.toUpperCase() - : AppLocalizations.of(context)!.loginInstead.toUpperCase(), + ? AppLocalizations.of(context).registerInstead.toUpperCase() + : AppLocalizations.of(context).loginInstead.toUpperCase(), ), onPressed: _switchAuthMode, ), TextButton( child: Text(_hideCustomServer - ? AppLocalizations.of(context)!.useCustomServer - : AppLocalizations.of(context)!.useDefaultServer), + ? AppLocalizations.of(context).useCustomServer + : AppLocalizations.of(context).useDefaultServer), key: Key('toggleCustomServerButton'), onPressed: () { setState(() { diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 056d72e74..8e23ec7b0 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -94,7 +94,7 @@ class _DashboardScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: WgerAppBar(AppLocalizations.of(context)!.labelDashboard), + appBar: WgerAppBar(AppLocalizations.of(context).labelDashboard), body: FutureBuilder( future: _initialData, builder: (ctx, authResultSnapshot) => @@ -103,7 +103,7 @@ class _DashboardScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - AppLocalizations.of(context)!.loadingText, + AppLocalizations.of(context).loadingText, style: Theme.of(context).textTheme.headline5, ), Padding(padding: EdgeInsets.symmetric(vertical: 8)), diff --git a/lib/screens/gallery_screen.dart b/lib/screens/gallery_screen.dart index 51b13045c..e6deed54f 100644 --- a/lib/screens/gallery_screen.dart +++ b/lib/screens/gallery_screen.dart @@ -35,7 +35,7 @@ class GalleryScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: WgerAppBar(AppLocalizations.of(context)!.gallery), + appBar: WgerAppBar(AppLocalizations.of(context).gallery), floatingActionButton: FloatingActionButton( child: Icon(Icons.add), onPressed: () { @@ -43,7 +43,7 @@ class GalleryScreen extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.addImage, + AppLocalizations.of(context).addImage, ImageForm(), hasListView: true, ), diff --git a/lib/screens/home_tabs_screen.dart b/lib/screens/home_tabs_screen.dart index e6a82ba01..ec64217a2 100644 --- a/lib/screens/home_tabs_screen.dart +++ b/lib/screens/home_tabs_screen.dart @@ -58,26 +58,26 @@ class _HomeTabsScreenState extends State with SingleTickerProvid items: [ BottomNavigationBarItem( icon: Icon(Icons.dashboard), - label: AppLocalizations.of(context)!.labelDashboard, + label: AppLocalizations.of(context).labelDashboard, ), BottomNavigationBarItem( icon: Icon(Icons.fitness_center), - label: AppLocalizations.of(context)!.labelBottomNavWorkout, + label: AppLocalizations.of(context).labelBottomNavWorkout, ), BottomNavigationBarItem( icon: Icon(Icons.restaurant), - label: AppLocalizations.of(context)!.labelBottomNavNutrition, + label: AppLocalizations.of(context).labelBottomNavNutrition, ), BottomNavigationBarItem( icon: FaIcon( FontAwesomeIcons.weight, size: 20, ), - label: AppLocalizations.of(context)!.weight, + label: AppLocalizations.of(context).weight, ), BottomNavigationBarItem( icon: Icon(Icons.photo_library), - label: AppLocalizations.of(context)!.gallery, + label: AppLocalizations.of(context).gallery, ), ], type: BottomNavigationBarType.fixed, diff --git a/lib/screens/nutritional_plan_screen.dart b/lib/screens/nutritional_plan_screen.dart index faefdc1dc..9c2447324 100644 --- a/lib/screens/nutritional_plan_screen.dart +++ b/lib/screens/nutritional_plan_screen.dart @@ -61,7 +61,7 @@ class NutritionalPlanScreen extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.edit, + AppLocalizations.of(context).edit, PlanForm(_nutritionalPlan), ), ); @@ -77,12 +77,12 @@ class NutritionalPlanScreen extends StatelessWidget { return [ PopupMenuItem( value: NutritionalPlanOptions.edit, - child: Text(AppLocalizations.of(context)!.edit), + child: Text(AppLocalizations.of(context).edit), ), const PopupMenuDivider(), PopupMenuItem( value: NutritionalPlanOptions.delete, - child: Text(AppLocalizations.of(context)!.delete), + child: Text(AppLocalizations.of(context).delete), ), ]; }, diff --git a/lib/screens/nutritional_plans_screen.dart b/lib/screens/nutritional_plans_screen.dart index fbff380fd..5ca0a4195 100644 --- a/lib/screens/nutritional_plans_screen.dart +++ b/lib/screens/nutritional_plans_screen.dart @@ -31,7 +31,7 @@ class NutritionScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: WgerAppBar(AppLocalizations.of(context)!.nutritionalPlans), + appBar: WgerAppBar(AppLocalizations.of(context).nutritionalPlans), floatingActionButton: FloatingActionButton( child: const Icon(Icons.add), onPressed: () async { @@ -39,7 +39,7 @@ class NutritionScreen extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.newNutritionalPlan, + AppLocalizations.of(context).newNutritionalPlan, PlanForm(), ), ); diff --git a/lib/screens/weight_screen.dart b/lib/screens/weight_screen.dart index f8a321839..e19f4856f 100644 --- a/lib/screens/weight_screen.dart +++ b/lib/screens/weight_screen.dart @@ -29,7 +29,7 @@ class WeightScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: WgerAppBar(AppLocalizations.of(context)!.weight), + appBar: WgerAppBar(AppLocalizations.of(context).weight), floatingActionButton: FloatingActionButton( child: const Icon(Icons.add), onPressed: () async { @@ -37,7 +37,7 @@ class WeightScreen extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.newEntry, + AppLocalizations.of(context).newEntry, WeightForm(), ), ); diff --git a/lib/screens/workout_plan_screen.dart b/lib/screens/workout_plan_screen.dart index 56624a398..e60a45d41 100644 --- a/lib/screens/workout_plan_screen.dart +++ b/lib/screens/workout_plan_screen.dart @@ -96,7 +96,7 @@ class _WorkoutPlanScreenState extends State { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.edit, + AppLocalizations.of(context).edit, WorkoutForm(workoutPlan), ), ); @@ -120,18 +120,18 @@ class _WorkoutPlanScreenState extends State { return [ PopupMenuItem( child: _mode == WorkoutScreenMode.log - ? Text(AppLocalizations.of(context)!.labelWorkoutPlan) - : Text(AppLocalizations.of(context)!.labelWorkoutLogs), + ? Text(AppLocalizations.of(context).labelWorkoutPlan) + : Text(AppLocalizations.of(context).labelWorkoutLogs), value: WorkoutOptions.toggleMode, ), PopupMenuItem( value: WorkoutOptions.edit, - child: Text(AppLocalizations.of(context)!.edit), + child: Text(AppLocalizations.of(context).edit), ), const PopupMenuDivider(), PopupMenuItem( value: WorkoutOptions.delete, - child: Text(AppLocalizations.of(context)!.delete), + child: Text(AppLocalizations.of(context).delete), ), ]; }, diff --git a/lib/screens/workout_plans_screen.dart b/lib/screens/workout_plans_screen.dart index ebaad6596..a44125814 100644 --- a/lib/screens/workout_plans_screen.dart +++ b/lib/screens/workout_plans_screen.dart @@ -34,7 +34,7 @@ class WorkoutPlansScreen extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: WgerAppBar( - AppLocalizations.of(context)!.labelWorkoutPlans, + AppLocalizations.of(context).labelWorkoutPlans, ), floatingActionButton: FloatingActionButton( child: const Icon(Icons.add), @@ -43,7 +43,7 @@ class WorkoutPlansScreen extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.newWorkout, + AppLocalizations.of(context).newWorkout, WorkoutForm(WorkoutPlan.empty()), ), ); diff --git a/lib/widgets/app_drawer.dart b/lib/widgets/app_drawer.dart index 16ae7ca8b..e6891bb5f 100644 --- a/lib/widgets/app_drawer.dart +++ b/lib/widgets/app_drawer.dart @@ -39,7 +39,7 @@ class AppDrawer extends StatelessWidget { ListTile( //dense: true, leading: Icon(Icons.exit_to_app), - title: Text(AppLocalizations.of(context)!.logout), + title: Text(AppLocalizations.of(context).logout), onTap: () { Provider.of(context, listen: false).logout(); Provider.of(context, listen: false).clear(); diff --git a/lib/widgets/core/about.dart b/lib/widgets/core/about.dart index 9a87a8403..d53730196 100644 --- a/lib/widgets/core/about.dart +++ b/lib/widgets/core/about.dart @@ -17,9 +17,9 @@ */ import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:wger/providers/auth.dart'; class WgerAboutListTile extends StatelessWidget { @@ -52,15 +52,15 @@ class WgerAboutListTile extends StatelessWidget { aboutBoxChildren: [ SizedBox(height: 10), - Text(AppLocalizations.of(context)!.aboutDescription), + Text(AppLocalizations.of(context).aboutDescription), SizedBox(height: 20), ListTile( leading: Icon(Icons.code), - title: Text(AppLocalizations.of(context)!.aboutSourceTitle), + title: Text(AppLocalizations.of(context).aboutSourceTitle), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.aboutSourceText), + Text(AppLocalizations.of(context).aboutSourceText), Text( 'https://github.com/wger-project', style: TextStyle(color: Colors.blue), @@ -73,11 +73,11 @@ class WgerAboutListTile extends StatelessWidget { SizedBox(height: 10), ListTile( leading: Icon(Icons.bug_report), - title: Text(AppLocalizations.of(context)!.aboutBugsTitle), + title: Text(AppLocalizations.of(context).aboutBugsTitle), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.aboutBugsText), + Text(AppLocalizations.of(context).aboutBugsText), Text( 'https://github.com/wger-project/flutter/issues/new/choose', style: TextStyle(color: Colors.blue), @@ -91,11 +91,11 @@ class WgerAboutListTile extends StatelessWidget { SizedBox(height: 10), ListTile( leading: Icon(Icons.chat), - title: Text(AppLocalizations.of(context)!.aboutContactUsTitle), + title: Text(AppLocalizations.of(context).aboutContactUsTitle), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.aboutContactUsText), + Text(AppLocalizations.of(context).aboutContactUsText), Text( 'https://discord.gg/rPWFv6W', style: TextStyle(color: Colors.blue), @@ -108,11 +108,11 @@ class WgerAboutListTile extends StatelessWidget { SizedBox(height: 10), ListTile( leading: Icon(Icons.translate), - title: Text(AppLocalizations.of(context)!.aboutTranslationTitle), + title: Text(AppLocalizations.of(context).aboutTranslationTitle), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.aboutTranslationText), + Text(AppLocalizations.of(context).aboutTranslationText), Text( 'https://hosted.weblate.org/engage/wger/', style: TextStyle(color: Colors.blue), diff --git a/lib/widgets/core/app_bar.dart b/lib/widgets/core/app_bar.dart index c412a5b31..ccda920b5 100644 --- a/lib/widgets/core/app_bar.dart +++ b/lib/widgets/core/app_bar.dart @@ -44,7 +44,7 @@ class WgerAppBar extends StatelessWidget with PreferredSizeWidget { context: context, builder: (BuildContext context) { return AlertDialog( - title: Text(AppLocalizations.of(context)!.optionsLabel), + title: Text(AppLocalizations.of(context).optionsLabel), actions: [ TextButton( child: Text(MaterialLocalizations.of(context).closeButtonLabel), @@ -61,7 +61,7 @@ class WgerAppBar extends StatelessWidget with PreferredSizeWidget { ListTile( //dense: true, leading: Icon(Icons.exit_to_app), - title: Text(AppLocalizations.of(context)!.logout), + title: Text(AppLocalizations.of(context).logout), onTap: () { Provider.of(context, listen: false).logout(); Provider.of(context, listen: false).clear(); diff --git a/lib/widgets/dashboard/calendar.dart b/lib/widgets/dashboard/calendar.dart index 1e72a0b1b..34911c7cb 100644 --- a/lib/widgets/dashboard/calendar.dart +++ b/lib/widgets/dashboard/calendar.dart @@ -111,7 +111,7 @@ class _DashboardCalendarWidgetState extends State // Add events to lists _events[date]!.add(Event( EventType.session, - '${AppLocalizations.of(context)!.impression}: ${session.impressionAsString} $time', + '${AppLocalizations.of(context).impression}: ${session.impressionAsString} $time', )); } }); @@ -193,7 +193,7 @@ class _DashboardCalendarWidgetState extends State children: [ ListTile( title: Text( - AppLocalizations.of(context)!.calendar, + AppLocalizations.of(context).calendar, style: Theme.of(context).textTheme.headline4, ), leading: Icon( @@ -235,13 +235,13 @@ class _DashboardCalendarWidgetState extends State title: Text((() { switch (event.type) { case EventType.caloriesDiary: - return AppLocalizations.of(context)!.nutritionalDiary; + return AppLocalizations.of(context).nutritionalDiary; case EventType.session: - return AppLocalizations.of(context)!.workoutSession; + return AppLocalizations.of(context).workoutSession; case EventType.weight: - return AppLocalizations.of(context)!.weight; + return AppLocalizations.of(context).weight; } return event.description.toString(); })()), diff --git a/lib/widgets/dashboard/widgets.dart b/lib/widgets/dashboard/widgets.dart index 9cd552926..9d77adaf3 100644 --- a/lib/widgets/dashboard/widgets.dart +++ b/lib/widgets/dashboard/widgets.dart @@ -79,16 +79,16 @@ class _DashboardNutritionWidgetState extends State { mainAxisSize: MainAxisSize.min, children: [ MutedText( - '${meal.nutritionalValues.energy.toStringAsFixed(0)}${AppLocalizations.of(context)!.kcal}'), + '${meal.nutritionalValues.energy.toStringAsFixed(0)}${AppLocalizations.of(context).kcal}'), MutedText(' / '), MutedText( - '${meal.nutritionalValues.protein.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}'), + '${meal.nutritionalValues.protein.toStringAsFixed(0)}${AppLocalizations.of(context).g}'), MutedText(' / '), MutedText( - '${meal.nutritionalValues.carbohydrates.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}'), + '${meal.nutritionalValues.carbohydrates.toStringAsFixed(0)}${AppLocalizations.of(context).g}'), MutedText(' / '), MutedText( - '${meal.nutritionalValues.fat.toStringAsFixed(0)}${AppLocalizations.of(context)!.g} '), + '${meal.nutritionalValues.fat.toStringAsFixed(0)}${AppLocalizations.of(context).g} '), ], ), IconButton( @@ -99,7 +99,7 @@ class _DashboardNutritionWidgetState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.mealLogged, + AppLocalizations.of(context).mealLogged, textAlign: TextAlign.center, ), ), @@ -126,7 +126,7 @@ class _DashboardNutritionWidgetState extends State { ), ), SizedBox(width: 5), - Text('${item.amount.toStringAsFixed(0)} ${AppLocalizations.of(context)!.g}'), + Text('${item.amount.toStringAsFixed(0)} ${AppLocalizations.of(context).g}'), ], ), ], @@ -156,7 +156,7 @@ class _DashboardNutritionWidgetState extends State { children: [ ListTile( title: Text( - _hasContent ? _plan!.description : AppLocalizations.of(context)!.labelWorkoutPlan, + _hasContent ? _plan!.description : AppLocalizations.of(context).labelWorkoutPlan, style: Theme.of(context).textTheme.headline4, ), subtitle: Text( @@ -191,8 +191,8 @@ class _DashboardNutritionWidgetState extends State { ), ) : NothingFound( - AppLocalizations.of(context)!.noNutritionalPlans, - AppLocalizations.of(context)!.newNutritionalPlan, + AppLocalizations.of(context).noNutritionalPlans, + AppLocalizations.of(context).newNutritionalPlan, PlanForm(), ), if (_hasContent) @@ -200,7 +200,7 @@ class _DashboardNutritionWidgetState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( - child: Text(AppLocalizations.of(context)!.goToDetailPage), + child: Text(AppLocalizations.of(context).goToDetailPage), onPressed: () { Navigator.of(context) .pushNamed(NutritionalPlanScreen.routeName, arguments: _plan); @@ -231,7 +231,7 @@ class _DashboardWeightWidgetState extends State { children: [ ListTile( title: Text( - AppLocalizations.of(context)!.weight, + AppLocalizations.of(context).weight, style: Theme.of(context).textTheme.headline4, ), leading: FaIcon( @@ -245,7 +245,7 @@ class _DashboardWeightWidgetState extends State { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.newEntry, + AppLocalizations.of(context).newEntry, WeightForm(), ), ); @@ -261,8 +261,8 @@ class _DashboardWeightWidgetState extends State { child: WeightChartWidget(weightEntriesData.items), ) : NothingFound( - AppLocalizations.of(context)!.noWeightEntries, - AppLocalizations.of(context)!.newEntry, + AppLocalizations.of(context).noWeightEntries, + AppLocalizations.of(context).newEntry, WeightForm(), ), ], @@ -373,7 +373,7 @@ class _DashboardWorkoutWidgetState extends State { children: [ ListTile( title: Text( - _hasContent ? _workoutPlan!.name : AppLocalizations.of(context)!.labelWorkoutPlan, + _hasContent ? _workoutPlan!.name : AppLocalizations.of(context).labelWorkoutPlan, style: Theme.of(context).textTheme.headline4, ), subtitle: Text( @@ -403,8 +403,8 @@ class _DashboardWorkoutWidgetState extends State { ), ) : NothingFound( - AppLocalizations.of(context)!.noWorkoutPlans, - AppLocalizations.of(context)!.newWorkout, + AppLocalizations.of(context).noWorkoutPlans, + AppLocalizations.of(context).newWorkout, WorkoutForm(WorkoutPlan.empty()), ), if (_hasContent) @@ -412,7 +412,7 @@ class _DashboardWorkoutWidgetState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( - child: Text(AppLocalizations.of(context)!.goToDetailPage), + child: Text(AppLocalizations.of(context).goToDetailPage), onPressed: () { Navigator.of(context) .pushNamed(WorkoutPlanScreen.routeName, arguments: _workoutPlan); diff --git a/lib/widgets/exercises/exercises.dart b/lib/widgets/exercises/exercises.dart index 971c99dc2..c4c945afe 100644 --- a/lib/widgets/exercises/exercises.dart +++ b/lib/widgets/exercises/exercises.dart @@ -35,7 +35,7 @@ class ExerciseDetail extends StatelessWidget { children: [ // Category Text( - AppLocalizations.of(context)!.category, + AppLocalizations.of(context).category, style: Theme.of(context).textTheme.headline6, ), Text(_exercise.categoryObj.name), @@ -43,7 +43,7 @@ class ExerciseDetail extends StatelessWidget { // Equipment Text( - AppLocalizations.of(context)!.equipment, + AppLocalizations.of(context).equipment, style: Theme.of(context).textTheme.headline6, ), if (_exercise.equipment.length > 0) @@ -53,7 +53,7 @@ class ExerciseDetail extends StatelessWidget { // Muscles Text( - AppLocalizations.of(context)!.muscles, + AppLocalizations.of(context).muscles, style: Theme.of(context).textTheme.headline6, ), if (_exercise.muscles.length > 0) @@ -63,7 +63,7 @@ class ExerciseDetail extends StatelessWidget { // Muscles secondary Text( - AppLocalizations.of(context)!.musclesSecondary, + AppLocalizations.of(context).musclesSecondary, style: Theme.of(context).textTheme.headline6, ), if (_exercise.musclesSecondary.length > 0) @@ -73,7 +73,7 @@ class ExerciseDetail extends StatelessWidget { // Description Text( - AppLocalizations.of(context)!.description, + AppLocalizations.of(context).description, style: Theme.of(context).textTheme.headline6, ), Html(data: _exercise.description), diff --git a/lib/widgets/gallery/forms.dart b/lib/widgets/gallery/forms.dart index 81e8e323a..2e7fcbe92 100644 --- a/lib/widgets/gallery/forms.dart +++ b/lib/widgets/gallery/forms.dart @@ -83,7 +83,7 @@ class _ImageFormState extends State { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(AppLocalizations.of(context)!.selectImage), + Text(AppLocalizations.of(context).selectImage), SizedBox(height: 8), Icon(Icons.photo_camera), ], @@ -113,7 +113,7 @@ class _ImageFormState extends State { _showPicker(ImageSource.camera); }, leading: Icon(Icons.photo_camera), - title: Text(AppLocalizations.of(context)!.takePicture), + title: Text(AppLocalizations.of(context).takePicture), ), ListTile( onTap: () { @@ -121,7 +121,7 @@ class _ImageFormState extends State { _showPicker(ImageSource.gallery); }, leading: Icon(Icons.photo_library), - title: Text(AppLocalizations.of(context)!.chooseFromLibrary)) + title: Text(AppLocalizations.of(context).chooseFromLibrary)) ], ), ); @@ -133,7 +133,7 @@ class _ImageFormState extends State { ), TextFormField( key: Key('field-date'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.date), + decoration: InputDecoration(labelText: AppLocalizations.of(context).date), controller: dateController, onTap: () async { // Stop keyboard from appearing @@ -154,7 +154,7 @@ class _ImageFormState extends State { }, validator: (value) { if (widget._image.id == null && _file == null) { - return AppLocalizations.of(context)!.selectImage; + return AppLocalizations.of(context).selectImage; } return null; @@ -162,7 +162,7 @@ class _ImageFormState extends State { ), TextFormField( key: Key('field-description'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.description), + decoration: InputDecoration(labelText: AppLocalizations.of(context).description), minLines: 3, maxLines: 10, controller: descriptionController, @@ -172,7 +172,7 @@ class _ImageFormState extends State { ), ElevatedButton( key: Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { // Validate and save final isValid = _form.currentState!.validate(); diff --git a/lib/widgets/gallery/overview.dart b/lib/widgets/gallery/overview.dart index 366f67e6a..3fdb01768 100644 --- a/lib/widgets/gallery/overview.dart +++ b/lib/widgets/gallery/overview.dart @@ -81,7 +81,7 @@ class Gallery extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.edit, + AppLocalizations.of(context).edit, ImageForm(currentImage), hasListView: true, ), diff --git a/lib/widgets/nutrition/charts.dart b/lib/widgets/nutrition/charts.dart index 35634e3b3..adcf263bc 100644 --- a/lib/widgets/nutrition/charts.dart +++ b/lib/widgets/nutrition/charts.dart @@ -45,12 +45,12 @@ class NutritionalPlanPieChartWidget extends StatelessWidget { domainFn: (datum, index) => datum[0], measureFn: (datum, index) => datum[1], data: [ - [AppLocalizations.of(context)!.protein, _nutritionalValues.protein], - [AppLocalizations.of(context)!.fat, _nutritionalValues.fat], - [AppLocalizations.of(context)!.carbohydrates, _nutritionalValues.carbohydrates], + [AppLocalizations.of(context).protein, _nutritionalValues.protein], + [AppLocalizations.of(context).fat, _nutritionalValues.fat], + [AppLocalizations.of(context).carbohydrates, _nutritionalValues.carbohydrates], ], labelAccessorFn: (List row, _) => - '${row[0]}\n${row[1].toStringAsFixed(0)}${AppLocalizations.of(context)!.g}', + '${row[0]}\n${row[1].toStringAsFixed(0)}${AppLocalizations.of(context).g}', ) ], defaultRenderer: new charts.ArcRendererConfig( @@ -67,7 +67,7 @@ class NutritionalDiaryChartWidget extends StatelessWidget { NutritionalDiaryChartWidget({ Key? key, required NutritionalPlan nutritionalPlan, - }) : _nutritionalPlan = nutritionalPlan, + }) : _nutritionalPlan = nutritionalPlan, super(key: key); @override diff --git a/lib/widgets/nutrition/forms.dart b/lib/widgets/nutrition/forms.dart index b60b39aae..25fb30ecb 100644 --- a/lib/widgets/nutrition/forms.dart +++ b/lib/widgets/nutrition/forms.dart @@ -52,7 +52,7 @@ class MealForm extends StatelessWidget { children: [ TextFormField( key: Key('field-time'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.time), + decoration: InputDecoration(labelText: AppLocalizations.of(context).time), controller: _timeController, onTap: () async { // Stop keyboard from appearing @@ -73,7 +73,7 @@ class MealForm extends StatelessWidget { ), ElevatedButton( key: Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { if (!_form.currentState!.validate()) { return; @@ -124,7 +124,7 @@ class MealItemForm extends StatelessWidget { TypeAheadFormField( textFieldConfiguration: TextFieldConfiguration( controller: this._ingredientController, - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.ingredient), + decoration: InputDecoration(labelText: AppLocalizations.of(context).ingredient), ), suggestionsCallback: (pattern) async { return await Provider.of(context, listen: false) @@ -148,13 +148,13 @@ class MealItemForm extends StatelessWidget { }, validator: (value) { if (value!.isEmpty) { - return AppLocalizations.of(context)!.selectIngredient; + return AppLocalizations.of(context).selectIngredient; } return null; }, ), TextFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.weight), + decoration: InputDecoration(labelText: AppLocalizations.of(context).weight), controller: _amountController, keyboardType: TextInputType.number, onFieldSubmitted: (_) {}, @@ -165,13 +165,13 @@ class MealItemForm extends StatelessWidget { try { double.parse(value!); } catch (error) { - return AppLocalizations.of(context)!.enterValidNumber; + return AppLocalizations.of(context).enterValidNumber; } return null; }, ), ElevatedButton( - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { if (!_form.currentState!.validate()) { return; @@ -215,7 +215,7 @@ class PlanForm extends StatelessWidget { // Description TextFormField( key: Key('field-description'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.description), + decoration: InputDecoration(labelText: AppLocalizations.of(context).description), controller: _descriptionController, onFieldSubmitted: (_) {}, onSaved: (newValue) { @@ -224,7 +224,7 @@ class PlanForm extends StatelessWidget { ), ElevatedButton( key: Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { // Validate and save the current values to the weightEntry final isValid = _form.currentState!.validate(); diff --git a/lib/widgets/nutrition/meal.dart b/lib/widgets/nutrition/meal.dart index 335f0d4d5..f0c5ecd84 100644 --- a/lib/widgets/nutrition/meal.dart +++ b/lib/widgets/nutrition/meal.dart @@ -62,25 +62,25 @@ class _MealWidgetState extends State { children: [ Expanded( child: MutedText( - AppLocalizations.of(context)!.energy, + AppLocalizations.of(context).energy, textAlign: TextAlign.center, ), ), Expanded( child: MutedText( - AppLocalizations.of(context)!.protein, + AppLocalizations.of(context).protein, textAlign: TextAlign.center, ), ), Expanded( child: MutedText( - AppLocalizations.of(context)!.carbohydrates, + AppLocalizations.of(context).carbohydrates, textAlign: TextAlign.center, ), ), Expanded( child: MutedText( - AppLocalizations.of(context)!.fat, + AppLocalizations.of(context).fat, textAlign: TextAlign.center, ), ), @@ -89,13 +89,13 @@ class _MealWidgetState extends State { ), ...widget._meal.mealItems.map((item) => MealItemWidget(item, _expanded)).toList(), OutlinedButton( - child: Text(AppLocalizations.of(context)!.addIngredient), + child: Text(AppLocalizations.of(context).addIngredient), onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.addIngredient, + AppLocalizations.of(context).addIngredient, MealItemForm(widget._meal), hasListView: true, ), @@ -120,11 +120,11 @@ class MealItemWidget extends StatelessWidget { // TODO: add real support for weight units /* String unit = _item.weightUnitId == null - ? AppLocalizations.of(context)!.g + ? AppLocalizations.of(context).g : _item.weightUnitObj!.weightUnit.name; */ - String unit = AppLocalizations.of(context)!.g; + String unit = AppLocalizations.of(context).g; final values = _item.nutritionalValues; return Container( @@ -155,7 +155,7 @@ class MealItemWidget extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.successfullyDeleted, + AppLocalizations.of(context).successfullyDeleted, textAlign: TextAlign.center, )), ); @@ -169,25 +169,25 @@ class MealItemWidget extends StatelessWidget { children: [ Expanded( child: MutedText( - '${values.energy.toStringAsFixed(0)} ${AppLocalizations.of(context)!.kcal}', + '${values.energy.toStringAsFixed(0)} ${AppLocalizations.of(context).kcal}', textAlign: TextAlign.center, ), ), Expanded( child: MutedText( - '${values.protein.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}', + '${values.protein.toStringAsFixed(0)}${AppLocalizations.of(context).g}', textAlign: TextAlign.center, ), ), Expanded( child: MutedText( - '${values.carbohydrates.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}', + '${values.carbohydrates.toStringAsFixed(0)}${AppLocalizations.of(context).g}', textAlign: TextAlign.center, ), ), Expanded( child: MutedText( - '${values.fat.toStringAsFixed(0)}${AppLocalizations.of(context)!.g}', + '${values.fat.toStringAsFixed(0)}${AppLocalizations.of(context).g}', textAlign: TextAlign.center, ), ), @@ -219,7 +219,7 @@ class DismissibleMealHeader extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.edit, + AppLocalizations.of(context).edit, MealForm(_meal.planId, _meal), ), ); @@ -273,7 +273,7 @@ class DismissibleMealHeader extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - AppLocalizations.of(context)!.logMeal, + AppLocalizations.of(context).logMeal, style: TextStyle(color: Colors.white), ), Icon( @@ -293,7 +293,7 @@ class DismissibleMealHeader extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.successfullyDeleted, + AppLocalizations.of(context).successfullyDeleted, textAlign: TextAlign.center, ), ), @@ -305,7 +305,7 @@ class DismissibleMealHeader extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.mealLogged, + AppLocalizations.of(context).mealLogged, textAlign: TextAlign.center, ), ), diff --git a/lib/widgets/nutrition/nutritional_plan_detail.dart b/lib/widgets/nutrition/nutritional_plan_detail.dart index bee910c18..b0c688723 100644 --- a/lib/widgets/nutrition/nutritional_plan_detail.dart +++ b/lib/widgets/nutrition/nutritional_plan_detail.dart @@ -42,13 +42,13 @@ class NutritionalPlanDetailWidget extends StatelessWidget { Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton( - child: Text(AppLocalizations.of(context)!.addMeal), + child: Text(AppLocalizations.of(context).addMeal), onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.addMeal, + AppLocalizations.of(context).addMeal, MealForm(_nutritionalPlan.id!), ), ); @@ -70,14 +70,14 @@ class NutritionalPlanDetailWidget extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ - Text(AppLocalizations.of(context)!.energy), - Text(AppLocalizations.of(context)!.protein), - Text(AppLocalizations.of(context)!.carbohydrates), - Text(AppLocalizations.of(context)!.sugars), - Text(AppLocalizations.of(context)!.fat), - Text(AppLocalizations.of(context)!.saturatedFat), - Text(AppLocalizations.of(context)!.fibres), - Text(AppLocalizations.of(context)!.sodium), + Text(AppLocalizations.of(context).energy), + Text(AppLocalizations.of(context).protein), + Text(AppLocalizations.of(context).carbohydrates), + Text(AppLocalizations.of(context).sugars), + Text(AppLocalizations.of(context).fat), + Text(AppLocalizations.of(context).saturatedFat), + Text(AppLocalizations.of(context).fibres), + Text(AppLocalizations.of(context).sodium), ], ), ), @@ -100,14 +100,14 @@ class NutritionalPlanDetailWidget extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.kcal), - Text(AppLocalizations.of(context)!.g), - Text(AppLocalizations.of(context)!.g), - Text(AppLocalizations.of(context)!.g), - Text(AppLocalizations.of(context)!.g), - Text(AppLocalizations.of(context)!.g), - Text(AppLocalizations.of(context)!.g), - Text(AppLocalizations.of(context)!.g), + Text(AppLocalizations.of(context).kcal), + Text(AppLocalizations.of(context).g), + Text(AppLocalizations.of(context).g), + Text(AppLocalizations.of(context).g), + Text(AppLocalizations.of(context).g), + Text(AppLocalizations.of(context).g), + Text(AppLocalizations.of(context).g), + Text(AppLocalizations.of(context).g), ], ), ], @@ -115,7 +115,7 @@ class NutritionalPlanDetailWidget extends StatelessWidget { ), Padding(padding: const EdgeInsets.all(8.0)), Text( - AppLocalizations.of(context)!.nutritionalDiary, + AppLocalizations.of(context).nutritionalDiary, style: Theme.of(context).textTheme.headline6, ), Container( @@ -135,17 +135,17 @@ class NutritionalPlanDetailWidget extends StatelessWidget { children: [ Text(''), Text( - '${AppLocalizations.of(context)!.energy} (${AppLocalizations.of(context)!.kcal})'), + '${AppLocalizations.of(context).energy} (${AppLocalizations.of(context).kcal})'), Text( - '${AppLocalizations.of(context)!.protein} (${AppLocalizations.of(context)!.g})'), + '${AppLocalizations.of(context).protein} (${AppLocalizations.of(context).g})'), Text( - '${AppLocalizations.of(context)!.carbohydrates} (${AppLocalizations.of(context)!.g})'), + '${AppLocalizations.of(context).carbohydrates} (${AppLocalizations.of(context).g})'), Text( - '${AppLocalizations.of(context)!.sugars} (${AppLocalizations.of(context)!.g})'), + '${AppLocalizations.of(context).sugars} (${AppLocalizations.of(context).g})'), Text( - '${AppLocalizations.of(context)!.fat} (${AppLocalizations.of(context)!.g})'), + '${AppLocalizations.of(context).fat} (${AppLocalizations.of(context).g})'), Text( - '${AppLocalizations.of(context)!.saturatedFat} (${AppLocalizations.of(context)!.g})'), + '${AppLocalizations.of(context).saturatedFat} (${AppLocalizations.of(context).g})'), ], ), ), diff --git a/lib/widgets/nutrition/nutritional_plans_list.dart b/lib/widgets/nutrition/nutritional_plans_list.dart index c44a6a900..5cf6c603d 100644 --- a/lib/widgets/nutrition/nutritional_plans_list.dart +++ b/lib/widgets/nutrition/nutritional_plans_list.dart @@ -42,7 +42,7 @@ class NutritionalPlansList extends StatelessWidget { builder: (BuildContext contextDialog) { return AlertDialog( content: Text( - AppLocalizations.of(context)!.confirmDelete(currentPlan.description), + AppLocalizations.of(context).confirmDelete(currentPlan.description), ), actions: [ TextButton( @@ -51,7 +51,7 @@ class NutritionalPlansList extends StatelessWidget { ), TextButton( child: Text( - AppLocalizations.of(context)!.delete, + AppLocalizations.of(context).delete, style: TextStyle(color: Theme.of(context).errorColor), ), onPressed: () { @@ -65,7 +65,7 @@ class NutritionalPlansList extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.successfullyDeleted, + AppLocalizations.of(context).successfullyDeleted, textAlign: TextAlign.center, ), ), diff --git a/lib/widgets/weight/entries_list.dart b/lib/widgets/weight/entries_list.dart index 2de1c2e05..48f075548 100644 --- a/lib/widgets/weight/entries_list.dart +++ b/lib/widgets/weight/entries_list.dart @@ -55,7 +55,7 @@ class WeightEntriesList extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.successfullyDeleted, + AppLocalizations.of(context).successfullyDeleted, textAlign: TextAlign.center, ), ), @@ -69,7 +69,7 @@ class WeightEntriesList extends StatelessWidget { context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.edit, + AppLocalizations.of(context).edit, WeightForm(currentEntry), ), ); diff --git a/lib/widgets/weight/forms.dart b/lib/widgets/weight/forms.dart index 1c35581ec..7a4762087 100644 --- a/lib/widgets/weight/forms.dart +++ b/lib/widgets/weight/forms.dart @@ -47,7 +47,7 @@ class WeightForm extends StatelessWidget { children: [ // Weight date TextFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.date), + decoration: InputDecoration(labelText: AppLocalizations.of(context).date), controller: dateController, onTap: () async { // Stop keyboard from appearing @@ -82,7 +82,7 @@ class WeightForm extends StatelessWidget { // Weight TextFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.weight), + decoration: InputDecoration(labelText: AppLocalizations.of(context).weight), controller: weightController, keyboardType: TextInputType.number, onSaved: (newValue) { @@ -90,18 +90,18 @@ class WeightForm extends StatelessWidget { }, validator: (value) { if (value!.isEmpty) { - return AppLocalizations.of(context)!.enterValue; + return AppLocalizations.of(context).enterValue; } try { double.parse(value); } catch (error) { - return AppLocalizations.of(context)!.enterValidNumber; + return AppLocalizations.of(context).enterValidNumber; } return null; }, ), ElevatedButton( - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { // Validate and save the current values to the weightEntry final isValid = _form.currentState!.validate(); diff --git a/lib/widgets/workouts/charts.dart b/lib/widgets/workouts/charts.dart index 49b5b0f3b..86823ed15 100644 --- a/lib/widgets/workouts/charts.dart +++ b/lib/widgets/workouts/charts.dart @@ -41,7 +41,7 @@ class LogChartWidget extends StatelessWidget { [ ..._data['chart_data'].map((e) { return charts.Series( - id: '${e.first['reps']} ${AppLocalizations.of(context)!.reps}', + id: '${e.first['reps']} ${AppLocalizations.of(context).reps}', domainFn: (datum, index) => datum.time, measureFn: (datum, index) => datum.weight, data: [ diff --git a/lib/widgets/workouts/day.dart b/lib/widgets/workouts/day.dart index c9b5b4674..c9e9c77d2 100644 --- a/lib/widgets/workouts/day.dart +++ b/lib/widgets/workouts/day.dart @@ -153,13 +153,13 @@ class _WorkoutDayWidgetState extends State { ) .toList(), OutlinedButton( - child: Text(AppLocalizations.of(context)!.addSet), + child: Text(AppLocalizations.of(context).addSet), onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.newSet, + AppLocalizations.of(context).newSet, SetFormWidget(widget._day), hasListView: true, backgroundColor: wgerBackground, @@ -184,7 +184,7 @@ class DayHeaderDismissible extends StatelessWidget { required Day day, required bool expanded, required Function toggle, - }) : _day = day, + }) : _day = day, _expanded = expanded, _toggle = toggle; @@ -247,7 +247,7 @@ class DayHeaderDismissible extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - AppLocalizations.of(context)!.gymMode, + AppLocalizations.of(context).gymMode, style: TextStyle(color: Colors.white), ), Icon( diff --git a/lib/widgets/workouts/forms.dart b/lib/widgets/workouts/forms.dart index c9afc7387..2afd5d659 100644 --- a/lib/widgets/workouts/forms.dart +++ b/lib/widgets/workouts/forms.dart @@ -56,13 +56,13 @@ class WorkoutForm extends StatelessWidget { children: [ TextFormField( key: Key('field-name'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.name), + decoration: InputDecoration(labelText: AppLocalizations.of(context).name), controller: workoutNameController, validator: (value) { const minLength = 5; const maxLength = 100; if (value!.isEmpty || value.length < minLength || value.length > maxLength) { - return AppLocalizations.of(context)!.enterCharacters(minLength, maxLength); + return AppLocalizations.of(context).enterCharacters(minLength, maxLength); } return null; }, @@ -73,7 +73,7 @@ class WorkoutForm extends StatelessWidget { ), TextFormField( key: Key('field-description'), - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.description), + decoration: InputDecoration(labelText: AppLocalizations.of(context).description), minLines: 3, maxLines: 10, controller: workoutDescriptionController, @@ -81,7 +81,7 @@ class WorkoutForm extends StatelessWidget { const minLength = 0; const maxLength = 1000; if (value!.length > maxLength) { - return AppLocalizations.of(context)!.enterCharacters(minLength, maxLength); + return AppLocalizations.of(context).enterCharacters(minLength, maxLength); } return null; }, @@ -92,7 +92,7 @@ class WorkoutForm extends StatelessWidget { ), ElevatedButton( key: Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { // Validate and save final isValid = _form.currentState!.validate(); @@ -182,8 +182,8 @@ class _DayFormWidgetState extends State { TextFormField( key: Key('field-description'), decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.description, - helperText: AppLocalizations.of(context)!.dayDescriptionHelp, + labelText: AppLocalizations.of(context).description, + helperText: AppLocalizations.of(context).dayDescriptionHelp, helperMaxLines: 3, ), controller: widget.dayController, @@ -194,7 +194,7 @@ class _DayFormWidgetState extends State { const minLength = 5; const maxLength = 100; if (value!.isEmpty || value.length < minLength || value.length > maxLength) { - return AppLocalizations.of(context)!.enterCharacters(minLength, maxLength); + return AppLocalizations.of(context).enterCharacters(minLength, maxLength); } if (widget._day.daysOfWeek.length == 0) { @@ -207,7 +207,7 @@ class _DayFormWidgetState extends State { ...Day.weekdays.keys.map((dayNr) => DayCheckbox(dayNr, widget._day)).toList(), ElevatedButton( key: Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { if (!_form.currentState!.validate()) { return; @@ -314,7 +314,7 @@ class _SetFormWidgetState extends State { child: Column( //crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.nrOfSets(_currentSetSliderValue.round())), + Text(AppLocalizations.of(context).nrOfSets(_currentSetSliderValue.round())), Slider( value: _currentSetSliderValue, min: 1, @@ -331,7 +331,7 @@ class _SetFormWidgetState extends State { ), if (widget._set.settings.length > 0) SwitchListTile( - title: Text(AppLocalizations.of(context)!.setUnitsAndRir), + title: Text(AppLocalizations.of(context).setUnitsAndRir), value: _detailed, onChanged: (value) { setState(() { @@ -352,7 +352,7 @@ class _SetFormWidgetState extends State { textFieldConfiguration: TextFieldConfiguration( controller: this._exercisesController, decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.searchExercise, + labelText: AppLocalizations.of(context).searchExercise, prefixIcon: Icon(Icons.search), suffixIcon: IconButton( icon: Icon(Icons.help), @@ -363,9 +363,9 @@ class _SetFormWidgetState extends State { content: Column( mainAxisSize: MainAxisSize.min, children: [ - Text(AppLocalizations.of(context)!.selectExercises), + Text(AppLocalizations.of(context).selectExercises), SizedBox(height: 10), - Text(AppLocalizations.of(context)!.sameRepetitions) + Text(AppLocalizations.of(context).sameRepetitions) ], ), actions: [ @@ -418,7 +418,7 @@ class _SetFormWidgetState extends State { validator: (value) { // At least one exercise must be selected if (widget._set.exercisesIds.length == 0) { - return AppLocalizations.of(context)!.selectExercise; + return AppLocalizations.of(context).selectExercise; } // At least one setting has to be filled in @@ -426,7 +426,7 @@ class _SetFormWidgetState extends State { .where((s) => s.weight == null && s.reps == null) .length == widget._set.settings.length) { - return AppLocalizations.of(context)!.enterRepetitionsOrWeight; + return AppLocalizations.of(context).enterRepetitionsOrWeight; } return null; }, @@ -447,7 +447,7 @@ class _SetFormWidgetState extends State { }).toList(), ElevatedButton( key: Key(SUBMIT_BUTTON_KEY_NAME), - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { final isValid = _formKey.currentState!.validate(); if (!isValid) { @@ -519,7 +519,7 @@ class ExerciseSetting extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - AppLocalizations.of(context)!.setNr(i + 1), + AppLocalizations.of(context).setNr(i + 1), style: Theme.of(context).textTheme.headline6, ), Row( @@ -566,7 +566,7 @@ class ExerciseSetting extends StatelessWidget { textBaseline: TextBaseline.alphabetic, children: [ Text( - AppLocalizations.of(context)!.setNr(i + 1), + AppLocalizations.of(context).setNr(i + 1), style: TextStyle(fontWeight: FontWeight.bold), ), SizedBox(width: 10), @@ -611,8 +611,8 @@ class ExerciseSetting extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text(AppLocalizations.of(context)!.repetitions), - Text(AppLocalizations.of(context)!.weight), + Text(AppLocalizations.of(context).repetitions), + Text(AppLocalizations.of(context).weight), ], ), getRows(context), @@ -634,7 +634,7 @@ class RepsInputWidget extends StatelessWidget { Widget build(BuildContext context) { return TextFormField( decoration: InputDecoration( - labelText: _detailed ? AppLocalizations.of(context)!.repetitions : '', + labelText: _detailed ? AppLocalizations.of(context).repetitions : '', errorMaxLines: 2, ), controller: _repsController, @@ -645,7 +645,7 @@ class RepsInputWidget extends StatelessWidget { double.parse(value!); } } catch (error) { - return AppLocalizations.of(context)!.enterValidNumber; + return AppLocalizations.of(context).enterValidNumber; } return null; }, @@ -671,7 +671,7 @@ class WeightInputWidget extends StatelessWidget { Widget build(BuildContext context) { return TextFormField( decoration: InputDecoration( - labelText: _detailed ? AppLocalizations.of(context)!.weight : '', + labelText: _detailed ? AppLocalizations.of(context).weight : '', errorMaxLines: 2, ), controller: _weightController, @@ -682,7 +682,7 @@ class WeightInputWidget extends StatelessWidget { double.parse(value!); } } catch (error) { - return AppLocalizations.of(context)!.enterValidNumber; + return AppLocalizations.of(context).enterValidNumber; } return null; }, @@ -715,7 +715,7 @@ class _RiRInputWidgetState extends State { @override Widget build(BuildContext context) { return DropdownButtonFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.rir), + decoration: InputDecoration(labelText: AppLocalizations.of(context).rir), value: widget.dropdownValue, onSaved: (String? newValue) { widget._setting.setRir(newValue!); @@ -754,7 +754,7 @@ class _WeightUnitInputWidgetState extends State { return DropdownButtonFormField( value: selectedWeightUnit, - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.weightUnit), + decoration: InputDecoration(labelText: AppLocalizations.of(context).weightUnit), onChanged: (WeightUnit? newValue) { setState(() { selectedWeightUnit = newValue!; @@ -791,7 +791,7 @@ class _RepetitionUnitInputWidgetState extends State { return DropdownButtonFormField( value: selectedWeightUnit, - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.repetitionUnit), + decoration: InputDecoration(labelText: AppLocalizations.of(context).repetitionUnit), isDense: true, onChanged: (RepetitionUnit? newValue) { setState(() { diff --git a/lib/widgets/workouts/gym_mode.dart b/lib/widgets/workouts/gym_mode.dart index e9974d617..a47e07607 100644 --- a/lib/widgets/workouts/gym_mode.dart +++ b/lib/widgets/workouts/gym_mode.dart @@ -138,7 +138,7 @@ class StartPage extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Text( - AppLocalizations.of(context)!.todaysWorkout, + AppLocalizations.of(context).todaysWorkout, style: Theme.of(context).textTheme.headline4, ), ), @@ -170,7 +170,7 @@ class StartPage extends StatelessWidget { ), ), ElevatedButton( - child: Text(AppLocalizations.of(context)!.start), + child: Text(AppLocalizations.of(context).start), onPressed: () { _controller.nextPage(duration: Duration(milliseconds: 200), curve: Curves.bounceIn); }, @@ -240,7 +240,7 @@ class _LogPageState extends State { Widget getRepsWidget() { return TextFormField( decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.repetitions, + labelText: AppLocalizations.of(context).repetitions, suffixIcon: IconButton( icon: Icon( Icons.add, @@ -279,7 +279,7 @@ class _LogPageState extends State { try { int.parse(value!); } catch (error) { - return AppLocalizations.of(context)!.enterValidNumber; + return AppLocalizations.of(context).enterValidNumber; } return null; }, @@ -289,7 +289,7 @@ class _LogPageState extends State { Widget getWeightWidget() { return TextFormField( decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.weight, + labelText: AppLocalizations.of(context).weight, suffixIcon: IconButton( icon: Icon( Icons.add, @@ -327,7 +327,7 @@ class _LogPageState extends State { try { double.parse(value!); } catch (error) { - return AppLocalizations.of(context)!.enterValidNumber; + return AppLocalizations.of(context).enterValidNumber; } return null; }, @@ -361,7 +361,7 @@ class _LogPageState extends State { ? ListView( children: [ Text( - AppLocalizations.of(context)!.labelWorkoutLogs, + AppLocalizations.of(context).labelWorkoutLogs, style: Theme.of(context).textTheme.headline6, textAlign: TextAlign.center, ), @@ -369,12 +369,10 @@ class _LogPageState extends State { .filterLogsByExercise(widget._exercise, unique: true) .map((log) { return ListTile( - //title: Text(log.id.toString()), title: Text(log.singleLogRepText.replaceAll('\n', '')), subtitle: Text( DateFormat.yMd(Localizations.localeOf(context).languageCode) .format(log.date)), - trailing: Icon(Icons.copy), onTap: () { setState(() { @@ -429,7 +427,7 @@ class _LogPageState extends State { if (_detailed) RiRInputWidget(widget._log), /* TextFormField( - decoration: InputDecoration(labelText: AppLocalizations.of(context)!.comment), + decoration: InputDecoration(labelText: AppLocalizations.of(context).comment), controller: _commentController, keyboardType: TextInputType.multiline, maxLines: 3, @@ -449,7 +447,7 @@ class _LogPageState extends State { }, ), ElevatedButton( - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { // Validate and save the current values to the weightEntry final isValid = _form.currentState!.validate(); @@ -466,7 +464,7 @@ class _LogPageState extends State { SnackBar( duration: Duration(seconds: 2), // default is 4 content: Text( - AppLocalizations.of(context)!.successfullySaved, + AppLocalizations.of(context).successfullySaved, textAlign: TextAlign.center, ), ), @@ -593,7 +591,7 @@ class _SessionPageState extends State { Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Text( - AppLocalizations.of(context)!.workoutSession, + AppLocalizations.of(context).workoutSession, style: Theme.of(context).textTheme.headline5, ), ), @@ -636,7 +634,7 @@ class _SessionPageState extends State { ), TextFormField( decoration: InputDecoration( - labelText: AppLocalizations.of(context)!.notes, + labelText: AppLocalizations.of(context).notes, ), maxLines: 3, controller: notesController, @@ -651,7 +649,7 @@ class _SessionPageState extends State { Flexible( child: TextFormField( decoration: - InputDecoration(labelText: AppLocalizations.of(context)!.timeStart), + InputDecoration(labelText: AppLocalizations.of(context).timeStart), controller: timeStartController, onFieldSubmitted: (_) {}, onTap: () async { @@ -675,7 +673,7 @@ class _SessionPageState extends State { Flexible( child: TextFormField( decoration: - InputDecoration(labelText: AppLocalizations.of(context)!.timeEnd), + InputDecoration(labelText: AppLocalizations.of(context).timeEnd), controller: timeEndController, onFieldSubmitted: (_) {}, onTap: () async { @@ -698,7 +696,7 @@ class _SessionPageState extends State { ], ), ElevatedButton( - child: Text(AppLocalizations.of(context)!.save), + child: Text(AppLocalizations.of(context).save), onPressed: () async { // Validate and save the current values to the weightEntry final isValid = _form.currentState!.validate(); diff --git a/lib/widgets/workouts/workout_logs.dart b/lib/widgets/workouts/workout_logs.dart index e9f74732e..54003d454 100644 --- a/lib/widgets/workouts/workout_logs.dart +++ b/lib/widgets/workouts/workout_logs.dart @@ -49,26 +49,26 @@ class _WorkoutLogsState extends State { Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: Text( - AppLocalizations.of(context)!.labelWorkoutLogs, + AppLocalizations.of(context).labelWorkoutLogs, style: Theme.of(context).textTheme.headline5, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( - AppLocalizations.of(context)!.logHelpEntries, + AppLocalizations.of(context).logHelpEntries, textAlign: TextAlign.justify, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( - AppLocalizations.of(context)!.logHelpEntriesUnits, + AppLocalizations.of(context).logHelpEntriesUnits, textAlign: TextAlign.justify, ), ), ElevatedButton( - child: Text(AppLocalizations.of(context)!.labelWorkoutPlan), + child: Text(AppLocalizations.of(context).labelWorkoutPlan), onPressed: () { widget._changeMode(WorkoutScreenMode.workout); }, diff --git a/lib/widgets/workouts/workout_plan_detail.dart b/lib/widgets/workouts/workout_plan_detail.dart index 41a3b4a32..cd6c61d5d 100644 --- a/lib/widgets/workouts/workout_plan_detail.dart +++ b/lib/widgets/workouts/workout_plan_detail.dart @@ -52,13 +52,13 @@ class _WorkoutPlanDetailState extends State { Column( children: [ ElevatedButton( - child: Text(AppLocalizations.of(context)!.newDay), + child: Text(AppLocalizations.of(context).newDay), onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, arguments: FormScreenArguments( - AppLocalizations.of(context)!.newDay, + AppLocalizations.of(context).newDay, DayFormWidget(widget._workoutPlan), hasListView: true, ), @@ -67,7 +67,7 @@ class _WorkoutPlanDetailState extends State { ), if (widget._workoutPlan.days.length > 0) ElevatedButton( - child: Text(AppLocalizations.of(context)!.labelWorkoutLogs), + child: Text(AppLocalizations.of(context).labelWorkoutLogs), onPressed: () { widget._changeMode(WorkoutScreenMode.log); }, diff --git a/lib/widgets/workouts/workout_plans_list.dart b/lib/widgets/workouts/workout_plans_list.dart index 9c66686fb..bf3059a6d 100644 --- a/lib/widgets/workouts/workout_plans_list.dart +++ b/lib/widgets/workouts/workout_plans_list.dart @@ -44,7 +44,7 @@ class WorkoutPlansList extends StatelessWidget { builder: (BuildContext contextDialog) { return AlertDialog( content: Text( - AppLocalizations.of(context)!.confirmDelete(currentWorkout.name), + AppLocalizations.of(context).confirmDelete(currentWorkout.name), ), actions: [ TextButton( @@ -53,7 +53,7 @@ class WorkoutPlansList extends StatelessWidget { ), TextButton( child: Text( - AppLocalizations.of(context)!.delete, + AppLocalizations.of(context).delete, style: TextStyle(color: Theme.of(context).errorColor), ), onPressed: () { @@ -68,7 +68,7 @@ class WorkoutPlansList extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - AppLocalizations.of(context)!.successfullyDeleted, + AppLocalizations.of(context).successfullyDeleted, textAlign: TextAlign.center, ), ), diff --git a/pubspec.lock b/pubspec.lock index 4c1ffae9e..dfa8ebc51 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -259,7 +259,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.1" fixnum: dependency: transitive description: @@ -433,7 +433,7 @@ packages: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.7.5" + version: "0.7.5+2" image_picker_for_web: dependency: transitive description: @@ -739,7 +739,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -788,7 +788,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" timing: dependency: transitive description: @@ -928,7 +928,7 @@ packages: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.6" win32: dependency: transitive description: