chore: migrate deprecation code && code cleanup (#708)

Fixes all issues in `flutter analyze`.
<Reviewed>

Commits:
* chore: migrate deprecated text style

* chore: migrate `toggleableActiveColor` to individual theme

* chore: don't use 'BuildContext's across async gaps
This commit is contained in:
EvadeMaster 2023-02-19 10:16:49 +07:00
parent dc665f227e
commit 3ae4d69110
No known key found for this signature in database
GPG Key ID: 90BAB50981420F89
16 changed files with 189 additions and 51 deletions

View File

@ -40,6 +40,51 @@ var darkCustomTheme = ThemeData(
), ),
canvasColor: const Color(0xff1B1A1D), canvasColor: const Color(0xff1B1A1D),
scaffoldBackgroundColor: const Color(0xff1B1A1D), scaffoldBackgroundColor: const Color(0xff1B1A1D),
toggleableActiveColor: const Color(0xffA5CAFF),
textTheme: GoogleFonts.robotoTextTheme(ThemeData.dark().textTheme), textTheme: GoogleFonts.robotoTextTheme(ThemeData.dark().textTheme),
switchTheme: SwitchThemeData(
thumbColor:
MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return const Color(0xffA5CAFF);
}
return null;
}),
trackColor:
MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return const Color(0xffA5CAFF);
}
return null;
}),
),
radioTheme: RadioThemeData(
fillColor:
MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return const Color(0xffA5CAFF);
}
return null;
}),
),
checkboxTheme: CheckboxThemeData(
fillColor:
MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return const Color(0xffA5CAFF);
}
return null;
}),
),
); );

View File

@ -41,8 +41,53 @@ class DynamicThemeBuilder extends StatelessWidget {
), ),
scaffoldBackgroundColor: lightColorScheme?.surface, scaffoldBackgroundColor: lightColorScheme?.surface,
colorScheme: lightColorScheme?.harmonized(), colorScheme: lightColorScheme?.harmonized(),
toggleableActiveColor: lightColorScheme?.primary,
textTheme: GoogleFonts.robotoTextTheme(ThemeData.light().textTheme), textTheme: GoogleFonts.robotoTextTheme(ThemeData.light().textTheme),
switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return lightColorScheme?.primary;
}
return null;
}),
trackColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return lightColorScheme?.primary;
}
return null;
}),
),
radioTheme: RadioThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return lightColorScheme?.primary;
}
return null;
}),
),
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return lightColorScheme?.primary;
}
return null;
}),
),
); );
final ThemeData darkDynamicTheme = ThemeData( final ThemeData darkDynamicTheme = ThemeData(
useMaterial3: true, useMaterial3: true,
@ -64,8 +109,53 @@ class DynamicThemeBuilder extends StatelessWidget {
), ),
scaffoldBackgroundColor: darkColorScheme?.surface, scaffoldBackgroundColor: darkColorScheme?.surface,
colorScheme: darkColorScheme?.harmonized(), colorScheme: darkColorScheme?.harmonized(),
toggleableActiveColor: darkColorScheme?.primary,
textTheme: GoogleFonts.robotoTextTheme(ThemeData.dark().textTheme), textTheme: GoogleFonts.robotoTextTheme(ThemeData.dark().textTheme),
switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return darkColorScheme?.primary;
}
return null;
}),
trackColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return darkColorScheme?.primary;
}
return null;
}),
),
radioTheme: RadioThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return darkColorScheme?.primary;
}
return null;
}),
),
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return null;
}
if (states.contains(MaterialState.selected)) {
return darkColorScheme?.primary;
}
return null;
}),
),
); );
return DynamicTheme( return DynamicTheme(
themeCollection: ThemeCollection( themeCollection: ThemeCollection(
@ -90,4 +180,4 @@ class DynamicThemeBuilder extends StatelessWidget {
}, },
); );
} }
} }

View File

@ -41,14 +41,14 @@ class _AppSelectorViewState extends State<AppSelectorView> {
child: Text( child: Text(
'', '',
style: TextStyle( style: TextStyle(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),
leading: IconButton( leading: IconButton(
icon: Icon( icon: Icon(
Icons.arrow_back, Icons.arrow_back,
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),

View File

@ -23,7 +23,7 @@ class ContributorsView extends StatelessWidget {
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),

View File

@ -34,7 +34,7 @@ class HomeView extends StatelessWidget {
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),
@ -48,7 +48,7 @@ class HomeView extends StatelessWidget {
'homeView.updatesSubtitle', 'homeView.updatesSubtitle',
child: Text( child: Text(
'', '',
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.titleLarge,
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
@ -61,7 +61,7 @@ class HomeView extends StatelessWidget {
'homeView.patchedSubtitle', 'homeView.patchedSubtitle',
child: Text( child: Text(
'', '',
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.titleLarge,
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),

View File

@ -28,7 +28,7 @@ class InstallerView extends StatelessWidget {
title: Text( title: Text(
model.headerLogs, model.headerLogs,
style: GoogleFonts.inter( style: GoogleFonts.inter(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
onBackButtonPressed: () => model.onWillPop(context), onBackButtonPressed: () => model.onWillPop(context),

View File

@ -34,7 +34,7 @@ class PatcherView extends StatelessWidget {
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),

View File

@ -52,31 +52,33 @@ class PatcherViewModel extends BaseViewModel {
Future<void> showPatchConfirmationDialog(BuildContext context) async { Future<void> showPatchConfirmationDialog(BuildContext context) async {
final bool isValid = await isValidPatchConfig(); final bool isValid = await isValidPatchConfig();
if (isValid) { if (context.mounted) {
navigateToInstaller(); if (isValid) {
} else { navigateToInstaller();
return showDialog( } else {
context: context, return showDialog(
builder: (context) => AlertDialog( context: context,
title: I18nText('warning'), builder: (context) => AlertDialog(
backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'),
content: I18nText('patcherView.patchDialogText'), backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
actions: <Widget>[ content: I18nText('patcherView.patchDialogText'),
CustomMaterialButton( actions: <Widget>[
isFilled: false, CustomMaterialButton(
label: I18nText('noButton'), isFilled: false,
onPressed: () => Navigator.of(context).pop(), label: I18nText('noButton'),
), onPressed: () => Navigator.of(context).pop(),
CustomMaterialButton( ),
label: I18nText('yesButton'), CustomMaterialButton(
onPressed: () { label: I18nText('yesButton'),
Navigator.of(context).pop(); onPressed: () {
navigateToInstaller(); Navigator.of(context).pop();
}, navigateToInstaller();
) },
], )
), ],
); ),
);
}
} }
} }
@ -114,7 +116,8 @@ class PatcherViewModel extends BaseViewModel {
await _managerAPI.getSelectedPatches(selectedApp!.originalPackageName); await _managerAPI.getSelectedPatches(selectedApp!.originalPackageName);
final List<Patch> patches = final List<Patch> patches =
_patcherAPI.getFilteredPatches(selectedApp!.originalPackageName); _patcherAPI.getFilteredPatches(selectedApp!.originalPackageName);
this.selectedPatches this
.selectedPatches
.addAll(patches.where((patch) => selectedPatches.contains(patch.name))); .addAll(patches.where((patch) => selectedPatches.contains(patch.name)));
notifyListeners(); notifyListeners();
} }

View File

@ -50,14 +50,14 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
child: Text( child: Text(
'', '',
style: TextStyle( style: TextStyle(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),
leading: IconButton( leading: IconButton(
icon: Icon( icon: Icon(
Icons.arrow_back, Icons.arrow_back,
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
@ -74,7 +74,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
child: Text( child: Text(
model.patchesVersion!, model.patchesVersion!,
style: TextStyle( style: TextStyle(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),

View File

@ -32,7 +32,7 @@ class SettingsView extends StatelessWidget {
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),

View File

@ -27,7 +27,7 @@ class AppInfoView extends StatelessWidget {
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
), ),
), ),
@ -51,13 +51,13 @@ class AppInfoView extends StatelessWidget {
Text( Text(
app.name, app.name,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.titleLarge,
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
app.version, app.version,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.titleLarge,
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
Padding( Padding(

View File

@ -28,7 +28,7 @@ class AvailableUpdatesCard extends StatelessWidget {
child: Text( child: Text(
'', '',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1!.copyWith( style: Theme.of(context).textTheme.titleMedium!.copyWith(
color: Theme.of(context).colorScheme.secondary, color: Theme.of(context).colorScheme.secondary,
), ),
), ),
@ -53,7 +53,7 @@ class AvailableUpdatesCard extends StatelessWidget {
// child: Text( // child: Text(
// '', // '',
// textAlign: TextAlign.center, // textAlign: TextAlign.center,
// style: Theme.of(context).textTheme.subtitle1!.copyWith( // style: Theme.of(context).textTheme.titleMedium!.copyWith(
// color: Theme.of(context).colorScheme.secondary, // color: Theme.of(context).colorScheme.secondary,
// ), // ),
// ), // ),

View File

@ -30,7 +30,7 @@ class InstalledAppsCard extends StatelessWidget {
child: Text( child: Text(
'', '',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1!.copyWith( style: Theme.of(context).textTheme.titleMedium!.copyWith(
color: Theme.of(context).colorScheme.secondary, color: Theme.of(context).colorScheme.secondary,
), ),
), ),

View File

@ -61,7 +61,7 @@ class OptionsFilePicker extends StatelessWidget {
child: Text( child: Text(
'Select File', 'Select File',
style: TextStyle( style: TextStyle(
color: Theme.of(context).textTheme.bodyText1?.color, color: Theme.of(context).textTheme.bodyLarge?.color,
), ),
), ),
), ),

View File

@ -17,7 +17,7 @@ class CustomChip extends StatelessWidget {
showCheckmark: false, showCheckmark: false,
label: label, label: label,
selected: isSelected, selected: isSelected,
labelStyle: Theme.of(context).textTheme.subtitle2!.copyWith( labelStyle: Theme.of(context).textTheme.titleSmall!.copyWith(
color: isSelected color: isSelected
? Theme.of(context).colorScheme.primary ? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.secondary, : Theme.of(context).colorScheme.secondary,

View File

@ -33,7 +33,7 @@ class CustomSliverAppBar extends StatelessWidget {
: IconButton( : IconButton(
icon: Icon( icon: Icon(
Icons.arrow_back, Icons.arrow_back,
color: Theme.of(context).textTheme.headline6!.color, color: Theme.of(context).textTheme.titleLarge!.color,
), ),
onPressed: onPressed:
onBackButtonPressed ?? () => Navigator.of(context).pop(), onBackButtonPressed ?? () => Navigator.of(context).pop(),