Whats happening
- Applying a font family all over my
CupertinoApp
usingCupertinoThemeData
. - Font family is used from
google_fonts
package.
Questions/issues
- The text theme specified in
CupertinoThemeData
isn't applying it toCupertinoActionSheet
andCupertinoAlertDialog
. - If
CupertinoThemeData
doesn't coverCupertinoActionSheet
,CupertinoAlertDialog
, etc, then how to specify a theme for them?
Related Code Blocks
Main file, CupertinoApp
:
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: AppConstants.name,
home: const SomeScreen(),
theme: CupertinoThemeData(
textTheme: CupertinoTextThemeData(
textStyle: AppConstants.appTextStyle,
navLargeTitleTextStyle: AppConstants.appTextStyle.copyWith(
fontSize: 30,
fontWeight: FontWeight.bold,
),
navActionTextStyle: AppConstants.appTextStyle.copyWith(
color: AppConstants.primaryColor,
),
navTitleTextStyle: AppConstants.appTextStyle.copyWith(
color: CupertinoColors.label,
),
actionTextStyle: AppConstants.appTextStyle.copyWith(
color: AppConstants.primaryColor,
),
tabLabelTextStyle: AppConstants.appTextStyle.copyWith(
color: CupertinoColors.label,
),
pickerTextStyle: AppConstants.appTextStyle.copyWith(
color: CupertinoColors.label,
),
dateTimePickerTextStyle: AppConstants.appTextStyle.copyWith(
color: CupertinoColors.label,
),
),
brightness: Brightness.dark,
primaryColor: AppConstants.primaryColor,
scaffoldBackgroundColor: AppConstants.bgColor,
),
);
Constants used:
class AppConstants {
static TextStyle appTextStyle = GoogleFonts.ubuntu(
color: CupertinoColors.label,
fontSize: 17,
);
}
Modal popup function:
showCupertinoModalPopup(
context: context,
builder: (context) {
return CupertinoActionSheet(
title: const Text('Sort By'),
actions: options // list of strings: ['Name', 'Date', 'Modified']
.map(
(option) => CupertinoActionSheetAction(
onPressed: () {},
child: Text(option),
),
)
.toList(),
cancelButton: CupertinoActionSheetAction(
onPressed: () {},
child: const Text('Cancel'),
),
);
},
);