fixed warnings (super.key, etc)

This commit is contained in:
Kima
2023-12-12 22:57:16 +01:00
parent fc3f538e6b
commit 6bac82f7d6
46 changed files with 349 additions and 228 deletions

View File

@@ -19,8 +19,7 @@ import 'package:filcnaplo_mobile_ui/common/widgets/absence/absence_view.i18n.dar
import 'package:provider/provider.dart';
class AbsenceSubjectView extends StatelessWidget {
const AbsenceSubjectView(this.subject, {Key? key, this.absences = const []})
: super(key: key);
const AbsenceSubjectView(this.subject, {super.key, this.absences = const []});
final GradeSubject subject;
final List<Absence> absences;

View File

@@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
class AbsenceSubjectViewContainer extends InheritedWidget {
const AbsenceSubjectViewContainer({Key? key, required Widget child}) : super(key: key, child: child);
const AbsenceSubjectViewContainer({super.key, required super.child});
static AbsenceSubjectViewContainer? of(BuildContext context) => context.dependOnInheritedWidgetOfExactType<AbsenceSubjectViewContainer>();
static AbsenceSubjectViewContainer? of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<AbsenceSubjectViewContainer>();
@override
bool updateShouldNotify(AbsenceSubjectViewContainer oldWidget) => false;

View File

@@ -1,3 +1,5 @@
// ignore_for_file: no_leading_underscores_for_local_identifiers
import 'dart:math';
import 'package:animations/animations.dart';
@@ -42,13 +44,13 @@ class SubjectAbsence {
}
class AbsencesPage extends StatefulWidget {
const AbsencesPage({Key? key}) : super(key: key);
const AbsencesPage({super.key});
@override
_AbsencesPageState createState() => _AbsencesPageState();
AbsencesPageState createState() => AbsencesPageState();
}
class _AbsencesPageState extends State<AbsencesPage>
class AbsencesPageState extends State<AbsencesPage>
with TickerProviderStateMixin {
late UserProvider user;
late AbsenceProvider absenceProvider;
@@ -308,10 +310,10 @@ class _AbsencesPageState extends State<AbsencesPage>
Animation<double> secondaryAnimation,
) {
return FadeThroughTransition(
child: child,
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
fillColor: Theme.of(context).colorScheme.background,
child: child,
);
},
child: Column(
@@ -359,7 +361,7 @@ class _AbsencesPageState extends State<AbsencesPage>
.length;
title1 = "stat_1".i18n;
title2 = "stat_2".i18n;
suffix = " " + "hr".i18n;
suffix = " ${"hr".i18n}";
} else if (activeData == AbsenceFilter.delays.index) {
value1 = absenceProvider.absences
.where((e) =>
@@ -373,7 +375,7 @@ class _AbsencesPageState extends State<AbsencesPage>
.fold(0, (a, b) => a + b);
title1 = "stat_3".i18n;
title2 = "stat_4".i18n;
suffix = " " + "min".i18n;
suffix = " ${"min".i18n}";
}
return Padding(

View File

@@ -17,16 +17,16 @@ final Map<int, String> avgDropItems = {
};
class AverageSelector extends StatefulWidget {
const AverageSelector({Key? key, this.onChanged, required this.value}) : super(key: key);
const AverageSelector({super.key, this.onChanged, required this.value});
final Function(int?)? onChanged;
final int value;
@override
_AverageSelectorState createState() => _AverageSelectorState();
AverageSelectorState createState() => AverageSelectorState();
}
class _AverageSelectorState extends State<AverageSelector> {
class AverageSelectorState extends State<AverageSelector> {
@override
Widget build(BuildContext context) {
List<DropdownMenuItem<int>> dropdownItems = avgDropItems.keys.map((item) {
@@ -47,14 +47,16 @@ class _AverageSelectorState extends State<AverageSelector> {
return DropdownButton2<int>(
items: dropdownItems,
onChanged: (int? value) {
if (Provider.of<PremiumProvider>(context, listen: false).hasScope(PremiumScopes.gradeStats)) {
if (Provider.of<PremiumProvider>(context, listen: false)
.hasScope(PremiumScopes.gradeStats)) {
if (widget.onChanged != null) {
setState(() {
widget.onChanged!(value);
});
}
} else {
PremiumLockedFeatureUpsell.show(context: context, feature: PremiumFeature.gradestats);
PremiumLockedFeatureUpsell.show(
context: context, feature: PremiumFeature.gradestats);
}
},
value: widget.value,
@@ -84,10 +86,9 @@ class _AverageSelectorState extends State<AverageSelector> {
children: [
Text(
avgDropItems[widget.value]!.i18n,
style: Theme.of(context)
.textTheme
.titleSmall!
.copyWith(fontWeight: FontWeight.w600, color: AppColors.of(context).text.withOpacity(0.65)),
style: Theme.of(context).textTheme.titleSmall!.copyWith(
fontWeight: FontWeight.w600,
color: AppColors.of(context).text.withOpacity(0.65)),
),
const SizedBox(
width: 4,

View File

@@ -1,24 +1,18 @@
import 'package:filcnaplo/api/providers/database_provider.dart';
import 'package:filcnaplo/api/providers/user_provider.dart';
import 'package:filcnaplo/models/settings.dart';
import 'package:filcnaplo_kreta_api/client/client.dart';
// import 'package:filcnaplo/api/providers/database_provider.dart';
// import 'package:filcnaplo/api/providers/user_provider.dart';
// import 'package:filcnaplo/models/settings.dart';
// import 'package:filcnaplo_kreta_api/client/client.dart';
import 'package:filcnaplo_kreta_api/providers/grade_provider.dart';
import 'package:filcnaplo_kreta_api/models/grade.dart';
class GradeCalculatorProvider extends GradeProvider {
GradeCalculatorProvider({
List<Grade> initialGrades = const [],
required SettingsProvider settings,
required UserProvider user,
required DatabaseProvider database,
required KretaClient kreta,
}) : super(
initialGrades: initialGrades,
settings: settings,
database: database,
kreta: kreta,
user: user,
);
super.initialGrades,
required super.settings,
required super.user,
required super.database,
required super.kreta,
});
List<Grade> _grades = [];
List<Grade> _ghosts = [];

View File

@@ -5,13 +5,14 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'grades_page.i18n.dart';
class FailWarning extends StatelessWidget {
const FailWarning({Key? key, required this.subjectAvgs}) : super(key: key);
const FailWarning({super.key, required this.subjectAvgs});
final Map<GradeSubject, double> subjectAvgs;
@override
Widget build(BuildContext context) {
final failingSubjectCount = subjectAvgs.values.where((avg) => avg < 2.0).length;
final failingSubjectCount =
subjectAvgs.values.where((avg) => avg < 2.0).length;
if (failingSubjectCount == 0) {
return const SizedBox();

View File

@@ -4,19 +4,24 @@ import 'package:filcnaplo_mobile_ui/pages/grades/grades_count_item.dart';
import 'package:collection/collection.dart';
class GradesCount extends StatelessWidget {
const GradesCount({Key? key, required this.grades}) : super(key: key);
const GradesCount({super.key, required this.grades});
final List<Grade> grades;
@override
Widget build(BuildContext context) {
List<int> gradesCount = List.generate(5, (int index) => grades.where((e) => e.value.value == index + 1).length);
List<int> gradesCount = List.generate(5,
(int index) => grades.where((e) => e.value.value == index + 1).length);
return Padding(
padding: const EdgeInsets.only(bottom: 6.0, top: 6.0, left: 12.0, right: 6.0),
padding:
const EdgeInsets.only(bottom: 6.0, top: 6.0, left: 12.0, right: 6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: gradesCount.mapIndexed((index, e) => GradesCountItem(count: e, value: index + 1)).toList(),
children: gradesCount
.mapIndexed(
(index, e) => GradesCountItem(count: e, value: index + 1))
.toList(),
),
);
}

View File

@@ -3,7 +3,7 @@ import 'package:filcnaplo_kreta_api/models/grade.dart';
import 'package:flutter/material.dart';
class GradesCountItem extends StatelessWidget {
const GradesCountItem({Key? key, required this.count, required this.value}) : super(key: key);
const GradesCountItem({super.key, required this.count, required this.value});
final int count;
final int value;
@@ -26,7 +26,8 @@ class GradesCountItem extends StatelessWidget {
style: const TextStyle(fontSize: 15.0),
),
const SizedBox(width: 5.0),
GradeValueWidget(GradeValue(value, "Value", "Value", 100), size: 19.0, fill: true, shadow: false),
GradeValueWidget(GradeValue(value, "Value", "Value", 100),
size: 19.0, fill: true, shadow: false),
],
);
}

View File

@@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
class SubjectGradesContainer extends InheritedWidget {
const SubjectGradesContainer({Key? key, required Widget child}) : super(key: key, child: child);
const SubjectGradesContainer({super.key, required super.child});
static SubjectGradesContainer? of(BuildContext context) => context.dependOnInheritedWidgetOfExactType<SubjectGradesContainer>();
static SubjectGradesContainer? of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<SubjectGradesContainer>();
@override
bool updateShouldNotify(SubjectGradesContainer oldWidget) => false;

View File

@@ -5,7 +5,8 @@ import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
class HeadsUpCountdown extends StatefulWidget {
const HeadsUpCountdown({Key? key, required this.maxTime, required this.elapsedTime}) : super(key: key);
const HeadsUpCountdown(
{super.key, required this.maxTime, required this.elapsedTime});
final double maxTime;
final double elapsedTime;
@@ -92,7 +93,8 @@ class _HeadsUpCountdownState extends State<HeadsUpCountdown> {
AnimatedOpacity(
opacity: dur.inSeconds > 0 ? 0.0 : 1.0,
duration: const Duration(milliseconds: 500),
child: Lottie.asset("assets/animations/bell-alert.json", width: 400),
child: Lottie.asset("assets/animations/bell-alert.json",
width: 400),
),
],
),

View File

@@ -10,7 +10,7 @@ enum ProgressAccuracy { minutes, seconds }
class LiveCardWidget extends StatefulWidget {
const LiveCardWidget({
Key? key,
super.key,
this.isEvent = false,
this.leading,
this.title,
@@ -26,7 +26,7 @@ class LiveCardWidget extends StatefulWidget {
this.progressAccuracy = ProgressAccuracy.minutes,
this.onProgressTap,
this.onTap,
}) : super(key: key);
});
final bool isEvent;
final String? leading;

View File

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:filcnaplo/utils/format.dart';
class DayTitle extends StatefulWidget {
const DayTitle({Key? key, required this.dayTitle, required this.controller}) : super(key: key);
const DayTitle({super.key, required this.dayTitle, required this.controller});
final String Function(int) dayTitle;
final TabController controller;
@@ -50,7 +50,11 @@ class _DayTitleState extends State<DayTitle> {
width: MediaQuery.of(context).size.width / 1.5,
child: Text(
widget.dayTitle(index).capital(),
style: TextStyle(color: AppColors.of(context).text.withOpacity(opacity), fontSize: 32.0, fontWeight: FontWeight.bold),
style: TextStyle(
color:
AppColors.of(context).text.withOpacity(opacity),
fontSize: 32.0,
fontWeight: FontWeight.bold),
),
);
},

View File

@@ -13,8 +13,7 @@ import 'package:i18n_extension/i18n_widget.dart';
import 'package:provider/provider.dart';
class FSTimetable extends StatefulWidget {
const FSTimetable({Key? key, required this.controller})
: super(key: key);
const FSTimetable({super.key, required this.controller});
final TimetableController controller;
@@ -81,7 +80,7 @@ class _FSTimetableState extends State<FSTimetable> {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text(
(index).toString()+".",
"$index.",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.secondary),
@@ -178,11 +177,11 @@ class _FSTimetableState extends State<FSTimetable> {
lessons[lessonIndex].subject.name.capital(),
maxLines: 1,
style: TextStyle(
fontStyle: lessons[lessonIndex]
.subject
.isRenamed && settings.renamedSubjectsItalics
? FontStyle.italic
: null,
fontStyle:
lessons[lessonIndex].subject.isRenamed &&
settings.renamedSubjectsItalics
? FontStyle.italic
: null,
),
overflow: TextOverflow.clip,
softWrap: false,

View File

@@ -32,8 +32,7 @@ import 'timetable_page.i18n.dart';
// todo: "fix" overflow (priority: -1)
class TimetablePage extends StatefulWidget {
const TimetablePage({Key? key, this.initialDay, this.initialWeek})
: super(key: key);
const TimetablePage({super.key, this.initialDay, this.initialWeek});
final DateTime? initialDay;
final Week? initialWeek;
@@ -58,10 +57,10 @@ class TimetablePage extends StatefulWidget {
}
@override
_TimetablePageState createState() => _TimetablePageState();
TimetablePageState createState() => TimetablePageState();
}
class _TimetablePageState extends State<TimetablePage>
class TimetablePageState extends State<TimetablePage>
with TickerProviderStateMixin, WidgetsBindingObserver {
late UserProvider user;
late TimetableProvider timetableProvider;
@@ -265,8 +264,8 @@ class _TimetablePageState extends State<TimetablePage>
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
transitionType: SharedAxisTransitionType.horizontal,
child: child,
fillColor: Theme.of(context).scaffoldBackgroundColor,
child: child,
);
},
layoutBuilder: (List<Widget> entries) {
@@ -319,6 +318,7 @@ class _TimetablePageState extends State<TimetablePage>
),
shadowColor: Theme.of(context).shadowColor,
bottom: PreferredSize(
preferredSize: const Size.fromHeight(50.0),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Row(
@@ -354,29 +354,7 @@ class _TimetablePageState extends State<TimetablePage>
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"${_controller.currentWeekId + 1}. " +
"week".i18n +
" (" +
// Week start
DateFormat(
(_controller.currentWeek.start.year !=
DateTime.now().year
? "yy. "
: "") +
"MMM d.",
I18n.of(context).locale.languageCode)
.format(_controller.currentWeek.start) +
" - " +
// Week end
DateFormat(
(_controller.currentWeek.start.year !=
DateTime.now().year
? "yy. "
: "") +
"MMM d.",
I18n.of(context).locale.languageCode)
.format(_controller.currentWeek.end) +
")",
"${_controller.currentWeekId + 1}. ${"week".i18n} (${DateFormat("${_controller.currentWeek.start.year != DateTime.now().year ? "yy. " : ""}MMM d.", I18n.of(context).locale.languageCode).format(_controller.currentWeek.start)} - ${DateFormat("${_controller.currentWeek.start.year != DateTime.now().year ? "yy. " : ""}MMM d.", I18n.of(context).locale.languageCode).format(_controller.currentWeek.end)})",
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 14.0,
@@ -398,7 +376,6 @@ class _TimetablePageState extends State<TimetablePage>
],
),
),
preferredSize: const Size.fromHeight(50.0),
),
),
],
@@ -409,10 +386,10 @@ class _TimetablePageState extends State<TimetablePage>
Animation<double> secondaryAnimation,
) {
return FadeThroughTransition(
child: child,
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
fillColor: Theme.of(context).scaffoldBackgroundColor,
child: child,
);
},
child: _controller.days != null