mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
dcm fix --only-rules=prefer-declaring-const-constructor lib
This commit is contained in:
@@ -11,7 +11,7 @@ final locator = GetIt.asNewInstance();
|
||||
class ServiceLocator {
|
||||
factory ServiceLocator() => _singleton;
|
||||
|
||||
ServiceLocator._internal();
|
||||
const ServiceLocator._internal();
|
||||
|
||||
static final ServiceLocator _singleton = ServiceLocator._internal();
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ part 'exercise_database.g.dart';
|
||||
|
||||
@DataClassName('ExerciseTable')
|
||||
class Exercises extends Table {
|
||||
const Exercises();
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text()();
|
||||
@@ -30,6 +31,7 @@ class Exercises extends Table {
|
||||
|
||||
@DataClassName('MuscleTable')
|
||||
class Muscles extends Table {
|
||||
const Muscles();
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const MuscleConverter())();
|
||||
@@ -37,6 +39,7 @@ class Muscles extends Table {
|
||||
|
||||
@DataClassName('CategoryTable')
|
||||
class Categories extends Table {
|
||||
const Categories();
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const ExerciseCategoryConverter())();
|
||||
@@ -44,6 +47,7 @@ class Categories extends Table {
|
||||
|
||||
@DataClassName('LanguagesTable')
|
||||
class Languages extends Table {
|
||||
const Languages();
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const LanguageConverter())();
|
||||
@@ -51,6 +55,7 @@ class Languages extends Table {
|
||||
|
||||
@DataClassName('EquipmentTable')
|
||||
class Equipments extends Table {
|
||||
const Equipments();
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text().map(const EquipmentConverter())();
|
||||
|
||||
@@ -9,6 +9,7 @@ part 'ingredients_database.g.dart';
|
||||
|
||||
@DataClassName('IngredientTable')
|
||||
class Ingredients extends Table {
|
||||
const Ingredients();
|
||||
IntColumn get id => integer()();
|
||||
|
||||
TextColumn get data => text()();
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
class NoResultException implements Exception {}
|
||||
class NoResultException implements Exception {
|
||||
const NoResultException();
|
||||
}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
class NoSuchEntryException implements Exception {}
|
||||
class NoSuchEntryException implements Exception {
|
||||
const NoSuchEntryException();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
// This widget is the root of your application.
|
||||
const MyApp(); // This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
|
||||
@@ -31,7 +31,7 @@ class Alias {
|
||||
@JsonKey(required: true)
|
||||
final String alias;
|
||||
|
||||
Alias({this.id, required this.exerciseId, required this.alias});
|
||||
const Alias({this.id, required this.exerciseId, required this.alias});
|
||||
|
||||
// Boilerplate
|
||||
factory Alias.fromJson(Map<String, dynamic> json) => _$AliasFromJson(json);
|
||||
|
||||
@@ -31,7 +31,7 @@ class Comment {
|
||||
@JsonKey(required: true)
|
||||
final String comment;
|
||||
|
||||
Comment({
|
||||
const Comment({
|
||||
required this.id,
|
||||
required this.exerciseId,
|
||||
required this.comment,
|
||||
|
||||
@@ -37,7 +37,7 @@ class ExerciseImage {
|
||||
@JsonKey(name: 'is_main', defaultValue: false)
|
||||
final bool isMain;
|
||||
|
||||
ExerciseImage({
|
||||
const ExerciseImage({
|
||||
required this.id,
|
||||
required this.uuid,
|
||||
required this.exerciseBaseId,
|
||||
|
||||
@@ -25,7 +25,7 @@ class Variation {
|
||||
@JsonKey(required: true)
|
||||
final int id;
|
||||
|
||||
Variation({required this.id});
|
||||
const Variation({required this.id});
|
||||
|
||||
// Boilerplate
|
||||
factory Variation.fromJson(Map<String, dynamic> json) => _$VariationFromJson(json);
|
||||
|
||||
@@ -39,7 +39,7 @@ class IngredientWeightUnit {
|
||||
@JsonKey(required: true)
|
||||
final double amount;
|
||||
|
||||
IngredientWeightUnit({
|
||||
const IngredientWeightUnit({
|
||||
required this.id,
|
||||
required this.weightUnit,
|
||||
required this.ingredient,
|
||||
|
||||
@@ -28,7 +28,7 @@ class WeightUnit {
|
||||
@JsonKey(required: true)
|
||||
final String name;
|
||||
|
||||
WeightUnit({required this.id, required this.name});
|
||||
const WeightUnit({required this.id, required this.name});
|
||||
|
||||
// Boilerplate
|
||||
factory WeightUnit.fromJson(Map<String, dynamic> json) => _$WeightUnitFromJson(json);
|
||||
|
||||
@@ -36,6 +36,7 @@ enum AuthMode {
|
||||
}
|
||||
|
||||
class AuthScreen extends StatelessWidget {
|
||||
const AuthScreen();
|
||||
static const routeName = '/auth';
|
||||
|
||||
@override
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:wger/widgets/dashboard/calendar.dart';
|
||||
import 'package:wger/widgets/dashboard/widgets.dart';
|
||||
|
||||
class DashboardScreen extends StatefulWidget {
|
||||
const DashboardScreen();
|
||||
static const routeName = '/dashboard';
|
||||
|
||||
@override
|
||||
|
||||
@@ -35,7 +35,7 @@ class FormScreenArguments {
|
||||
/// Padding for the whole content, default 15px on all sides
|
||||
final EdgeInsets padding;
|
||||
|
||||
FormScreenArguments(
|
||||
const FormScreenArguments(
|
||||
this.title,
|
||||
this.widget, {
|
||||
this.hasListView = false,
|
||||
@@ -44,6 +44,7 @@ class FormScreenArguments {
|
||||
}
|
||||
|
||||
class FormScreen extends StatelessWidget {
|
||||
const FormScreen();
|
||||
static const routeName = '/form';
|
||||
|
||||
@override
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:wger/providers/workout_plans.dart';
|
||||
import 'package:wger/widgets/workouts/gym_mode.dart';
|
||||
|
||||
class GymModeScreen extends StatelessWidget {
|
||||
const GymModeScreen();
|
||||
static const routeName = '/gym-mode';
|
||||
|
||||
@override
|
||||
|
||||
@@ -38,6 +38,7 @@ import 'package:wger/screens/weight_screen.dart';
|
||||
import 'package:wger/screens/workout_plans_screen.dart';
|
||||
|
||||
class HomeTabsScreen extends StatefulWidget {
|
||||
const HomeTabsScreen();
|
||||
static const routeName = '/dashboard2';
|
||||
|
||||
@override
|
||||
|
||||
@@ -28,10 +28,11 @@ class LogMealArguments {
|
||||
final Meal meal;
|
||||
final bool popTwice;
|
||||
|
||||
LogMealArguments(this.meal, this.popTwice);
|
||||
const LogMealArguments(this.meal, this.popTwice);
|
||||
}
|
||||
|
||||
class LogMealScreen extends StatefulWidget {
|
||||
const LogMealScreen();
|
||||
static const routeName = '/log-meal';
|
||||
|
||||
@override
|
||||
|
||||
@@ -22,6 +22,7 @@ import 'package:wger/models/nutrition/nutritional_plan.dart';
|
||||
import 'package:wger/widgets/nutrition/meal.dart';
|
||||
|
||||
class LogMealsScreen extends StatefulWidget {
|
||||
const LogMealsScreen();
|
||||
static const routeName = '/log-meals';
|
||||
|
||||
@override
|
||||
@@ -33,8 +34,7 @@ class _LogMealsScreenState extends State<LogMealsScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final nutritionalPlan =
|
||||
ModalRoute.of(context)!.settings.arguments as NutritionalPlan;
|
||||
final nutritionalPlan = ModalRoute.of(context)!.settings.arguments as NutritionalPlan;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
||||
@@ -25,6 +25,7 @@ import 'package:wger/widgets/measurements/categories.dart';
|
||||
import 'package:wger/widgets/measurements/forms.dart';
|
||||
|
||||
class MeasurementCategoriesScreen extends StatelessWidget {
|
||||
const MeasurementCategoriesScreen();
|
||||
static const routeName = '/measurement-categories';
|
||||
|
||||
@override
|
||||
|
||||
@@ -30,6 +30,7 @@ enum MeasurementOptions {
|
||||
}
|
||||
|
||||
class MeasurementEntriesScreen extends StatelessWidget {
|
||||
const MeasurementEntriesScreen();
|
||||
static const routeName = '/measurement-entries';
|
||||
|
||||
@override
|
||||
|
||||
@@ -31,10 +31,11 @@ class NutritionalDiaryArguments {
|
||||
/// Date to show data for
|
||||
final DateTime date;
|
||||
|
||||
NutritionalDiaryArguments(this.plan, this.date);
|
||||
const NutritionalDiaryArguments(this.plan, this.date);
|
||||
}
|
||||
|
||||
class NutritionalDiaryScreen extends StatelessWidget {
|
||||
const NutritionalDiaryScreen();
|
||||
static const routeName = '/nutritional-diary';
|
||||
|
||||
@override
|
||||
|
||||
@@ -33,6 +33,7 @@ enum NutritionalPlanOptions {
|
||||
}
|
||||
|
||||
class NutritionalPlanScreen extends StatelessWidget {
|
||||
const NutritionalPlanScreen();
|
||||
static const routeName = '/nutritional-plan-detail';
|
||||
|
||||
Future<NutritionalPlan> _loadFullPlan(BuildContext context, int planId) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:wger/widgets/nutrition/forms.dart';
|
||||
import 'package:wger/widgets/nutrition/nutritional_plans_list.dart';
|
||||
|
||||
class NutritionalPlansScreen extends StatelessWidget {
|
||||
const NutritionalPlansScreen();
|
||||
static const routeName = '/nutrition';
|
||||
|
||||
@override
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SplashScreen extends StatelessWidget {
|
||||
const SplashScreen();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Scaffold(
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class UpdateAppScreen extends StatelessWidget {
|
||||
const UpdateAppScreen();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:wger/widgets/weight/entries_list.dart';
|
||||
import 'package:wger/widgets/weight/forms.dart';
|
||||
|
||||
class WeightScreen extends StatelessWidget {
|
||||
const WeightScreen();
|
||||
static const routeName = '/weight';
|
||||
|
||||
@override
|
||||
|
||||
@@ -38,6 +38,7 @@ enum WorkoutOptions {
|
||||
}
|
||||
|
||||
class WorkoutPlanScreen extends StatefulWidget {
|
||||
const WorkoutPlanScreen();
|
||||
static const routeName = '/workout-plan-detail';
|
||||
|
||||
@override
|
||||
|
||||
@@ -27,6 +27,7 @@ import 'package:wger/widgets/workouts/forms.dart';
|
||||
import 'package:wger/widgets/workouts/workout_plans_list.dart';
|
||||
|
||||
class WorkoutPlansScreen extends StatelessWidget {
|
||||
const WorkoutPlansScreen();
|
||||
static const routeName = '/workout-plans-list';
|
||||
|
||||
@override
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:wger/providers/add_exercise.dart';
|
||||
import 'mixins/image_picker_mixin.dart';
|
||||
|
||||
class PreviewExerciseImages extends StatelessWidget with ExerciseImagePickerMixin {
|
||||
PreviewExerciseImages({super.key, required this.selectedImages});
|
||||
const PreviewExerciseImages({super.key, required this.selectedImages});
|
||||
|
||||
final List<File> selectedImages;
|
||||
@override
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class TextPrompt extends StatelessWidget {
|
||||
const TextPrompt();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
|
||||
@@ -43,7 +43,7 @@ class Event {
|
||||
final EventType _type;
|
||||
final String _description;
|
||||
|
||||
Event(this._type, this._description);
|
||||
const Event(this._type, this._description);
|
||||
|
||||
String get description {
|
||||
return _description;
|
||||
|
||||
@@ -52,6 +52,7 @@ import 'package:wger/widgets/workouts/forms.dart';
|
||||
enum viewMode { base, withMeals, withMealsDetails }
|
||||
|
||||
class DashboardNutritionWidget extends StatefulWidget {
|
||||
const DashboardNutritionWidget();
|
||||
@override
|
||||
_DashboardNutritionWidgetState createState() => _DashboardNutritionWidgetState();
|
||||
}
|
||||
@@ -249,6 +250,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
|
||||
}
|
||||
|
||||
class DashboardWeightWidget extends StatefulWidget {
|
||||
const DashboardWeightWidget();
|
||||
@override
|
||||
_DashboardWeightWidgetState createState() => _DashboardWeightWidgetState();
|
||||
}
|
||||
@@ -336,6 +338,7 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
|
||||
}
|
||||
|
||||
class DashboardMeasurementWidget extends StatefulWidget {
|
||||
const DashboardMeasurementWidget();
|
||||
@override
|
||||
_DashboardMeasurementWidgetState createState() => _DashboardMeasurementWidgetState();
|
||||
}
|
||||
@@ -455,6 +458,7 @@ class _DashboardMeasurementWidgetState extends State<DashboardMeasurementWidget>
|
||||
}
|
||||
|
||||
class DashboardWorkoutWidget extends StatefulWidget {
|
||||
const DashboardWorkoutWidget();
|
||||
@override
|
||||
_DashboardWorkoutWidgetState createState() => _DashboardWorkoutWidgetState();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:wger/providers/measurement.dart';
|
||||
import 'categories_card.dart';
|
||||
|
||||
class CategoriesList extends StatelessWidget {
|
||||
const CategoriesList();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = Provider.of<MeasurementProvider>(context, listen: false);
|
||||
|
||||
@@ -183,7 +183,7 @@ class NutritionData {
|
||||
final String name;
|
||||
final double value;
|
||||
|
||||
NutritionData(this.name, this.value);
|
||||
const NutritionData(this.name, this.value);
|
||||
}
|
||||
|
||||
class FlNutritionalPlanPieChartWidget extends StatefulWidget {
|
||||
|
||||
@@ -38,6 +38,7 @@ import 'package:wger/widgets/core/core.dart';
|
||||
import 'package:wger/widgets/nutrition/helpers.dart';
|
||||
|
||||
class ScanReader extends StatelessWidget {
|
||||
const ScanReader();
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
body: ReaderWidget(
|
||||
|
||||
@@ -28,6 +28,7 @@ import 'package:wger/widgets/measurements/charts.dart';
|
||||
import 'package:wger/widgets/weight/forms.dart';
|
||||
|
||||
class WeightEntriesList extends StatelessWidget {
|
||||
const WeightEntriesList();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final profile = context.read<UserProvider>().profile;
|
||||
|
||||
@@ -26,8 +26,8 @@ enum _WorkoutAppBarOptions {
|
||||
contribute,
|
||||
}
|
||||
|
||||
class WorkoutOverviewAppBar extends StatelessWidget
|
||||
implements PreferredSizeWidget {
|
||||
class WorkoutOverviewAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const WorkoutOverviewAppBar();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
|
||||
@@ -94,7 +94,7 @@ class WorkoutLogEvent {
|
||||
final WorkoutSession? session;
|
||||
final Map<Exercise, List<Log>> exercises;
|
||||
|
||||
WorkoutLogEvent(this.dateTime, this.session, this.exercises);
|
||||
const WorkoutLogEvent(this.dateTime, this.session, this.exercises);
|
||||
}
|
||||
|
||||
class WorkoutLogCalendar extends StatefulWidget {
|
||||
|
||||
Reference in New Issue
Block a user