FlexSubThemes class
Static sub-theme helpers used by opt-in widget sub theming in FlexColorScheme.
FlexSubTheme offers opinionated static theme helpers that are opt-in via FlexColorScheme.useSubThemes. You can also change many properties of the the opt-in setup by defining custom configuration values in the FlexSubThemesData configuration class, and passing it to the FlexColorScheme.subThemesData property.
The configuration class FlexSubThemesData offers easy to use configuration
properties for using these sub-themes in FlexColorScheme. You can also
the static sub-themes without using FlexColorScheme based theming.
However, the FlexSubThemesData has no impact on the static helpers, it
is FlexColorScheme that uses the FlexSubThemesData class to configure
the opt in sub-themes. You can of course also do this if you use
FlexSubThemesData outside of FlexColorScheme or in copyWith
on each
sub-theme with custom ThemeData.
Sub themes for the following widgets are provided and used via opt-in property FlexColorScheme.useSubThemes :
- TextButton
- ElevatedButton
- OutlinedButton
- Older buttons using ButtonThemeData
- ToggleButtons
- InputDecoration
- FloatingActionButton
- Chip
- Card
- PopupMenuButton
- Dialog
- TimePickerDialog
- SnackBar
- Tooltip
- BottomSheet
- BottomNavigationBar
- NavigationBar
In ToggleButtons hover, press, selected and focus states are not an exact match for the main buttons. It does not have as flexible styling as the main buttons. The theme mimics the style of the OutlinedButton for not selected buttons and the style of ElevatedButton for selected button. It does not support MaterialStateProperty and has only one state for different parts of the button. The selected and not selected, states would need different property values to be able to match the general buttons. It can therefore not fully match the same theme style as the Material states used on two different ButtonStyleButton buttons that it should match.
The theme ButtonThemeData is included to provide a very similar
theme style on the deprecated legacy buttons RaisedButton
,
OutlineButton
and FlatButton
as on the current main buttons. It is not
an exact match, since the legacy buttons do not offer as flexible
styling as the newer buttons. They do follow and match the styling on
ToggleButtons when it comes to hover, press, selected and focus.
Please consider phasing out the legacy buttons, as they are deprecated and
may soon be removed from the Flutter SDK.
The following widgets that have rounded corners are excluded from the sub theming:
- Tooltip, generally so small that larger prominent rounding the opinionated sub-theming is designed for, is not a good fit. FlexColorScheme does include out of the box theming options for tooltips, that also adapts to color branding when opting in on sub themes, it also gets a bit more rounded than when not opting in on sub themes.
- Scrollbar, rounding on edges of scrollbars are left to platform default.
- AppBar and BottomAppBar shape properties are left to their defaults.
- SnackBar the floating snackbar should be sub themed to also include border radius, but the none floating one should remain straight. Unclear if it can be done via SDK's current theming features, will investigate more in future version.
- Drawer should have 16dp default rounding on shown side edge, but in current version of Flutter SDK (2.8.1 when this was written) it has no theme property to enable this. It is coming in later Flutter version since it is required by the Material 3 design. When it is available, it will be added.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
- An opinionated BottomNavigationBarThemeData with custom elevation.
-
bottomSheetTheme(
{double? radius, double elevation = kBottomSheetElevation, double modalElevation = kBottomSheetModalElevation, Clip clipBehavior = Clip.antiAlias}) → BottomSheetThemeData - An opinionated BottomSheetThemeData with custom top corner radius.
- An opinionated ButtonThemeData theme.
-
cardTheme(
{double? radius, double elevation = kCardElevation, Clip clipBehavior = Clip.antiAlias}) → CardTheme - An opinionated CardTheme with custom corner radius and elevation.
-
chipTheme(
{required ColorScheme colorScheme, SchemeColor? baseSchemeColor, required TextStyle labelStyle, double? radius}) → ChipThemeData - An opinionated ChipThemeData with custom border radius and rather involved theme.
-
dialogTheme(
{double? radius, double? elevation = kDialogElevation, Color? backgroundColor}) → DialogTheme - An opinionated DialogTheme with custom corner radius and elevation.
-
elevatedButtonTheme(
{required ColorScheme colorScheme, double? radius, double elevation = kElevatedButtonElevation, EdgeInsetsGeometry? padding, Size minButtonSize = kButtonMinSize}) → ElevatedButtonThemeData - An opinionated ElevatedButtonThemeData theme.
-
floatingActionButtonTheme(
{double? radius, bool useShape = true}) → FloatingActionButtonThemeData - An opinionated FloatingActionButtonThemeData with custom border radius.
-
inputDecorationTheme(
{required ColorScheme colorScheme, SchemeColor? baseSchemeColor, double? radius, FlexInputBorderType borderType = FlexInputBorderType.outline, bool filled = true, Color? fillColor, double focusedBorderWidth = kThickBorderWidth, double unfocusedBorderWidth = kThinBorderWidth, double gapPadding = 4, bool unfocusedHasBorder = true}) → InputDecorationTheme - An opinionated OutlineInputBorder or UnderlineInputBorder using InputDecorationTheme, with optional fill color and adjustable corner radius.
- An opinionated NavigationBarThemeData with simpler API.
-
outlinedButtonTheme(
{required ColorScheme colorScheme, double? radius, double pressedOutlineWidth = kThickBorderWidth, double outlineWidth = kThinBorderWidth, EdgeInsetsGeometry? padding, Size minButtonSize = kButtonMinSize}) → OutlinedButtonThemeData - An opinionated OutlinedButtonThemeData theme.
-
popupMenuTheme(
{double? radius, double elevation = kPopupMenuElevation, Color? color}) → PopupMenuThemeData - An opinionated PopupMenuThemeData with custom corner radius.
-
schemeColor(
SchemeColor value, ColorScheme colorScheme) → Color -
Returns the Color from passed in ColorScheme in
colorScheme
corresponding to the SchemeColor enum selection invalue
. -
schemeColorPair(
SchemeColor value, ColorScheme colorScheme) → Color -
Returns the Color from passed in ColorScheme in
colorScheme
that is the color pair corresponding to the SchemeColor enum value passed in viavalue
. -
snackBarTheme(
{double? elevation = kSnackBarElevation, Color? backgroundColor}) → SnackBarThemeData - An opinionated SnackBarThemeData with custom elevation.
-
textButtonTheme(
{required ColorScheme colorScheme, double? radius, EdgeInsetsGeometry? padding, Size minButtonSize = kButtonMinSize}) → TextButtonThemeData - An opinionated TextButtonThemeData theme.
-
timePickerTheme(
{Color? backgroundColor, double? radius, double? elementRadius, InputDecorationTheme? inputDecorationTheme}) → TimePickerThemeData - An opinionated TimePickerThemeData with custom corner radius.
-
toggleButtonsTheme(
{required ColorScheme colorScheme, double? radius, double borderWidth = kThinBorderWidth, Size minButtonSize = kButtonMinSize, VisualDensity? visualDensity}) → ToggleButtonsThemeData - An opinionated ToggleButtonsThemeData theme.