dart fix --apply

This commit is contained in:
Dieter Plaetinck
2024-06-20 15:47:55 +03:00
parent 6e1d3f9568
commit 11ee38c03d
38 changed files with 72 additions and 72 deletions

View File

@@ -79,7 +79,7 @@ Widget createDashboardScreen({locale = 'en'}) {
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: wgerLightTheme,
home: DashboardScreen(),
home: const DashboardScreen(),
),
);
}

View File

@@ -35,7 +35,7 @@ Widget createWorkoutDetailScreen({locale = 'en'}) {
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: RouteSettings(arguments: workout),
builder: (_) => WorkoutPlanScreen(),
builder: (_) => const WorkoutPlanScreen(),
),
),
child: const SizedBox(),

View File

@@ -44,13 +44,13 @@ Widget createGymModeScreen({locale = 'en'}) {
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: RouteSettings(arguments: workout.days.first),
builder: (_) => GymModeScreen(),
builder: (_) => const GymModeScreen(),
),
),
child: const SizedBox(),
),
routes: {
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
WorkoutPlanScreen.routeName: (ctx) => const WorkoutPlanScreen(),
},
),
),

View File

@@ -25,7 +25,7 @@ Widget createMeasurementScreen({locale = 'en'}) {
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: wgerLightTheme,
home: MeasurementCategoriesScreen(),
home: const MeasurementCategoriesScreen(),
),
);
}

View File

@@ -34,7 +34,7 @@ Widget createNutritionalPlanScreen({locale = 'en'}) {
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: RouteSettings(arguments: getNutritionalPlanScreenshot()),
builder: (_) => NutritionalPlanScreen(),
builder: (_) => const NutritionalPlanScreen(),
),
),
child: const SizedBox(),

View File

@@ -35,9 +35,9 @@ Widget createWeightScreen({locale = 'en'}) {
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: wgerLightTheme,
home: WeightScreen(),
home: const WeightScreen(),
routes: {
FormScreen.routeName: (ctx) => FormScreen(),
FormScreen.routeName: (ctx) => const FormScreen(),
},
),
);

View File

@@ -13,7 +13,7 @@ class ServiceLocator {
const ServiceLocator._internal();
static final ServiceLocator _singleton = ServiceLocator._internal();
static const ServiceLocator _singleton = ServiceLocator._internal();
Future<void> _initDB() async {
ExerciseDatabase exerciseDB;

View File

@@ -64,7 +64,7 @@ void main() async {
// Locator to initialize exerciseDB
await ServiceLocator().configure();
// Application
runApp(MyApp());
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
@@ -142,30 +142,30 @@ class MyApp extends StatelessWidget {
highContrastDarkTheme: wgerDarkThemeHc,
themeMode: ThemeMode.system,
home: auth.isAuth
? HomeTabsScreen()
? const HomeTabsScreen()
: FutureBuilder(
future: auth.tryAutoLogin(),
builder: (ctx, authResultSnapshot) =>
authResultSnapshot.connectionState == ConnectionState.waiting
? SplashScreen()
: AuthScreen(),
? const SplashScreen()
: const AuthScreen(),
),
routes: {
DashboardScreen.routeName: (ctx) => DashboardScreen(),
FormScreen.routeName: (ctx) => FormScreen(),
DashboardScreen.routeName: (ctx) => const DashboardScreen(),
FormScreen.routeName: (ctx) => const FormScreen(),
GalleryScreen.routeName: (ctx) => const GalleryScreen(),
GymModeScreen.routeName: (ctx) => GymModeScreen(),
HomeTabsScreen.routeName: (ctx) => HomeTabsScreen(),
MeasurementCategoriesScreen.routeName: (ctx) => MeasurementCategoriesScreen(),
MeasurementEntriesScreen.routeName: (ctx) => MeasurementEntriesScreen(),
NutritionalPlansScreen.routeName: (ctx) => NutritionalPlansScreen(),
NutritionalDiaryScreen.routeName: (ctx) => NutritionalDiaryScreen(),
NutritionalPlanScreen.routeName: (ctx) => NutritionalPlanScreen(),
LogMealsScreen.routeName: (ctx) => LogMealsScreen(),
LogMealScreen.routeName: (ctx) => LogMealScreen(),
WeightScreen.routeName: (ctx) => WeightScreen(),
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
WorkoutPlansScreen.routeName: (ctx) => WorkoutPlansScreen(),
GymModeScreen.routeName: (ctx) => const GymModeScreen(),
HomeTabsScreen.routeName: (ctx) => const HomeTabsScreen(),
MeasurementCategoriesScreen.routeName: (ctx) => const MeasurementCategoriesScreen(),
MeasurementEntriesScreen.routeName: (ctx) => const MeasurementEntriesScreen(),
NutritionalPlansScreen.routeName: (ctx) => const NutritionalPlansScreen(),
NutritionalDiaryScreen.routeName: (ctx) => const NutritionalDiaryScreen(),
NutritionalPlanScreen.routeName: (ctx) => const NutritionalPlanScreen(),
LogMealsScreen.routeName: (ctx) => const LogMealsScreen(),
LogMealScreen.routeName: (ctx) => const LogMealScreen(),
WeightScreen.routeName: (ctx) => const WeightScreen(),
WorkoutPlanScreen.routeName: (ctx) => const WorkoutPlanScreen(),
WorkoutPlansScreen.routeName: (ctx) => const WorkoutPlansScreen(),
ExercisesScreen.routeName: (ctx) => const ExercisesScreen(),
ExerciseDetailScreen.routeName: (ctx) => const ExerciseDetailScreen(),
AddExerciseScreen.routeName: (ctx) => const AddExerciseScreen(),

View File

@@ -43,7 +43,7 @@ class MeasurementCategory extends Equatable {
MeasurementEntry findEntryById(entryId) {
return entries.firstWhere(
(entry) => entry.id == entryId,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}

View File

@@ -182,7 +182,7 @@ class ExercisesProvider with ChangeNotifier {
Exercise findExerciseById(int id) {
return exercises.firstWhere(
(base) => base.id == id,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}
@@ -208,7 +208,7 @@ class ExercisesProvider with ChangeNotifier {
ExerciseCategory findCategoryById(int id) {
return _categories.firstWhere(
(cat) => cat.id == id,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}
@@ -216,7 +216,7 @@ class ExercisesProvider with ChangeNotifier {
Equipment findEquipmentById(int id) {
return _equipment.firstWhere(
(equipment) => equipment.id == id,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}
@@ -224,7 +224,7 @@ class ExercisesProvider with ChangeNotifier {
Muscle findMuscleById(int id) {
return _muscles.firstWhere(
(muscle) => muscle.id == id,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}
@@ -232,7 +232,7 @@ class ExercisesProvider with ChangeNotifier {
Language findLanguageById(int id) {
return _languages.firstWhere(
(language) => language.id == id,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}

View File

@@ -44,7 +44,7 @@ class MeasurementProvider with ChangeNotifier {
MeasurementCategory findCategoryById(int id) {
return _categories.firstWhere(
(category) => category.id == id,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}

View File

@@ -75,7 +75,7 @@ class NutritionPlansProvider with ChangeNotifier {
NutritionalPlan findById(int id) {
return _plans.firstWhere(
(plan) => plan.id == id,
orElse: () => throw NoSuchEntryException(),
orElse: () => throw const NoSuchEntryException(),
);
}

View File

@@ -211,7 +211,7 @@ class _AuthCardState extends State<AuthCard> {
if (res.containsKey('action')) {
if (res['action'] == LoginActions.update && mounted) {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => UpdateAppScreen()),
MaterialPageRoute(builder: (context) => const UpdateAppScreen()),
);
return;
}

View File

@@ -35,15 +35,15 @@ class _DashboardScreenState extends State<DashboardScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: MainAppBar(AppLocalizations.of(context).labelDashboard),
body: SingleChildScrollView(
padding: const EdgeInsets.all(10),
body: const SingleChildScrollView(
padding: EdgeInsets.all(10),
child: Column(
children: [
DashboardWorkoutWidget(),
DashboardNutritionWidget(),
DashboardWeightWidget(),
DashboardMeasurementWidget(),
const DashboardCalendarWidget(),
DashboardCalendarWidget(),
],
),
),

View File

@@ -63,10 +63,10 @@ class _HomeTabsScreenState extends State<HomeTabsScreen> with SingleTickerProvid
}
final _screenList = [
DashboardScreen(),
WorkoutPlansScreen(),
NutritionalPlansScreen(),
WeightScreen(),
const DashboardScreen(),
const WorkoutPlansScreen(),
const NutritionalPlansScreen(),
const WeightScreen(),
const GalleryScreen(),
];

View File

@@ -46,7 +46,7 @@ class MeasurementCategoriesScreen extends StatelessWidget {
},
),
body: Consumer<MeasurementProvider>(
builder: (context, provider, child) => CategoriesList(),
builder: (context, provider, child) => const CategoriesList(),
),
);
}

View File

@@ -49,7 +49,7 @@ class WeightScreen extends StatelessWidget {
},
),
body: Consumer<BodyWeightProvider>(
builder: (context, workoutProvider, child) => WeightEntriesList(),
builder: (context, workoutProvider, child) => const WeightEntriesList(),
),
);
}

View File

@@ -33,7 +33,7 @@ class WorkoutPlansScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: WorkoutOverviewAppBar(),
appBar: const WorkoutOverviewAppBar(),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.pushNamed(

View File

@@ -40,7 +40,7 @@ class Gallery extends StatelessWidget {
child: RefreshIndicator(
onRefresh: () => provider.fetchAndSetGallery(),
child: provider.images.isEmpty
? TextPrompt()
? const TextPrompt()
: MasonryGridView.count(
crossAxisCount: 2,
mainAxisSpacing: 5,

View File

@@ -33,7 +33,7 @@ class NutritionalPlansList extends StatelessWidget {
return RefreshIndicator(
onRefresh: () => _nutritionProvider.fetchAndSetAllPlansSparse(),
child: _nutritionProvider.items.isEmpty
? TextPrompt()
? const TextPrompt()
: ListView.builder(
padding: const EdgeInsets.all(10.0),
itemCount: _nutritionProvider.items.length,

View File

@@ -92,7 +92,7 @@ class _IngredientTypeaheadState extends State<IngredientTypeahead> {
Future<String> readerscan(BuildContext context) async {
try {
final code = await Navigator.of(context)
.push<String?>(MaterialPageRoute(builder: (context) => ScanReader()));
.push<String?>(MaterialPageRoute(builder: (context) => const ScanReader()));
if (code == null) {
return '';
}

View File

@@ -34,7 +34,7 @@ class WorkoutPlansList extends StatelessWidget {
return RefreshIndicator(
onRefresh: () => _workoutProvider.fetchAndSetAllPlansSparse(),
child: _workoutProvider.items.isEmpty
? TextPrompt()
? const TextPrompt()
: ListView.builder(
padding: const EdgeInsets.all(10.0),
itemCount: _workoutProvider.items.length,

View File

@@ -63,10 +63,10 @@ void main() {
ChangeNotifierProvider(create: (ctx) => authProvider),
],
child: Consumer<AuthProvider>(
builder: (ctx, auth, _) => MaterialApp(
builder: (ctx, auth, _) => const MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('en'),
locale: Locale('en'),
home: AuthScreen(),
),
),

View File

@@ -49,7 +49,7 @@ void main() {
supportedLocales: AppLocalizations.supportedLocales,
home: const Gallery(),
routes: {
FormScreen.routeName: (ctx) => FormScreen(),
FormScreen.routeName: (ctx) => const FormScreen(),
},
),
);

View File

@@ -55,7 +55,7 @@ void main() {
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: MeasurementCategoriesScreen(),
home: const MeasurementCategoriesScreen(),
),
);
}

View File

@@ -55,7 +55,7 @@ void main() {
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: const RouteSettings(arguments: 1),
builder: (_) => MeasurementEntriesScreen(),
builder: (_) => const MeasurementEntriesScreen(),
),
),
child: Container(),

View File

@@ -64,7 +64,7 @@ void main() {
body: MealForm(1, meal),
),
routes: {
NutritionalPlanScreen.routeName: (ctx) => NutritionalPlanScreen(),
NutritionalPlanScreen.routeName: (ctx) => const NutritionalPlanScreen(),
},
),
);

View File

@@ -105,7 +105,7 @@ void main() {
),
),
routes: {
NutritionalPlanScreen.routeName: (ctx) => NutritionalPlanScreen(),
NutritionalPlanScreen.routeName: (ctx) => const NutritionalPlanScreen(),
},
),
);

View File

@@ -62,7 +62,7 @@ void main() {
body: PlanForm(plan),
),
routes: {
NutritionalPlanScreen.routeName: (ctx) => NutritionalPlanScreen(),
NutritionalPlanScreen.routeName: (ctx) => const NutritionalPlanScreen(),
},
),
);

View File

@@ -57,7 +57,7 @@ void main() {
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: RouteSettings(arguments: plan),
builder: (_) => NutritionalPlanScreen(),
builder: (_) => const NutritionalPlanScreen(),
),
),
child: const SizedBox(),

View File

@@ -73,9 +73,9 @@ void main() {
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: NutritionalPlansScreen(),
home: const NutritionalPlansScreen(),
routes: {
FormScreen.routeName: (ctx) => FormScreen(),
FormScreen.routeName: (ctx) => const FormScreen(),
},
),
);

View File

@@ -56,9 +56,9 @@ void main() {
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: WeightScreen(),
home: const WeightScreen(),
routes: {
FormScreen.routeName: (_) => FormScreen(),
FormScreen.routeName: (_) => const FormScreen(),
},
),
),

View File

@@ -61,13 +61,13 @@ void main() {
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: RouteSettings(arguments: workoutPlan.days.first),
builder: (_) => GymModeScreen(),
builder: (_) => const GymModeScreen(),
),
),
child: const SizedBox(),
),
routes: {
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
WorkoutPlanScreen.routeName: (ctx) => const WorkoutPlanScreen(),
},
),
),

View File

@@ -68,7 +68,7 @@ void main() {
body: RepetitionUnitInputWidget(setting1),
),
routes: {
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
WorkoutPlanScreen.routeName: (ctx) => const WorkoutPlanScreen(),
},
),
);

View File

@@ -69,7 +69,7 @@ void main() {
body: WeightUnitInputWidget(setting1),
),
routes: {
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
WorkoutPlanScreen.routeName: (ctx) => const WorkoutPlanScreen(),
},
),
);

View File

@@ -63,7 +63,7 @@ void main() {
body: WorkoutForm(workoutPlan),
),
routes: {
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
WorkoutPlanScreen.routeName: (ctx) => const WorkoutPlanScreen(),
},
),
);

View File

@@ -52,13 +52,13 @@ void main() {
onPressed: () => key.currentState!.push(
MaterialPageRoute<void>(
settings: RouteSettings(arguments: getWorkout()),
builder: (_) => WorkoutPlanScreen(),
builder: (_) => const WorkoutPlanScreen(),
),
),
child: const SizedBox(),
),
routes: {
WorkoutPlanScreen.routeName: (ctx) => WorkoutPlanScreen(),
WorkoutPlanScreen.routeName: (ctx) => const WorkoutPlanScreen(),
},
),
);

View File

@@ -70,9 +70,9 @@ void main() {
locale: Locale(locale),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: WorkoutPlansScreen(),
home: const WorkoutPlansScreen(),
routes: {
FormScreen.routeName: (ctx) => FormScreen(),
FormScreen.routeName: (ctx) => const FormScreen(),
},
),
);