Is it possible to apply a theme for the function? The idea is to stylize circular progress indicator color which appears when licenses are loading.
OutlinedButton(
onPressed: () {
showLicensePage( // how to apply theme to this function?
context: context,
applicationIcon: const MyAppIcon(48),
);
},
child: Text(
AppLocalizations.key(context, 'licenses'),
),
),
CodePudding user response:
The showLicensePage
function is really just a simple Navigator.push
.
void showLicensePage({
required BuildContext context,
String? applicationName,
String? applicationVersion,
Widget? applicationIcon,
String? applicationLegalese,
bool useRootNavigator = false,
}) {
assert(context != null);
assert(useRootNavigator != null);
Navigator.of(context, rootNavigator: useRootNavigator).push(MaterialPageRoute<void>(
builder: (BuildContext context) => LicensePage(
applicationName: applicationName,
applicationVersion: applicationVersion,
applicationIcon: applicationIcon,
applicationLegalese: applicationLegalese,
),
));
}
You can create your own showLicensePageWithTheme
where you wrap the LicensePage
with a Theme
widget:
void showLicensePageWithTheme({
required BuildContext context,
required ThemeData theme,
String? applicationName,
String? applicationVersion,
Widget? applicationIcon,
String? applicationLegalese,
bool useRootNavigator = false,
}) {
assert(context != null);
assert(useRootNavigator != null);
Navigator.of(context, rootNavigator: useRootNavigator)
.push(MaterialPageRoute<void>(
builder: (BuildContext context) => Theme(
data: theme,
child: LicensePage(
applicationName: applicationName,
applicationVersion: applicationVersion,
applicationIcon: applicationIcon,
applicationLegalese: applicationLegalese,
),
),
));
}