MREFieldsTheme class Theme

Field-only tokens: corner radius, padding, breakpoints and texts.

Colors and fonts stay in your ThemeData. Register this extension on it:

final app = MaterialApp(
  theme: ThemeData(
    extensions: const [
      MREFieldsTheme(
        fieldBorderRadius: 16,
        contentPadding: EdgeInsets.symmetric(horizontal: 20, vertical: 16),
      ),
    ],
  ),
  home: const HomePage(),
);

Order of priority: a widget parameter, then this extension, then MREFieldsTheme.defaults when nothing is registered.

Change one value and keep the rest with copyWith:

final tokens = MREFieldsTheme.defaults.copyWith(fieldBorderRadius: 4);

See also:

Inheritance
Annotations

Constructors

MREFieldsTheme({double fieldBorderRadius = defaultFieldBorderRadius, EdgeInsetsGeometry contentPadding = defaultContentPadding, EdgeInsetsGeometry expandedContentPadding = defaultExpandedContentPadding, double compactBreakpoint = defaultCompactBreakpoint, double expandedBreakpoint = defaultExpandedBreakpoint, MREFieldsStrings strings = const MREFieldsStrings()})
Creates field tokens. Omitted values keep their default.
const

Properties

compactBreakpoint → double
Width below which a field is MREWindowSize.compact.
final
contentPadding → EdgeInsetsGeometry
Padding inside the field on MREWindowSize.compact and MREWindowSize.medium.
final
expandedBreakpoint → double
Width from which a field is MREWindowSize.expanded.
final
expandedContentPadding → EdgeInsetsGeometry
Padding inside the field on MREWindowSize.expanded.
final
fieldBorderRadius → double
Corner radius of the field border.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
strings → MREFieldsStrings
User-visible text of the fields.
final
type → Object
The extension's type.
no setterinherited

Methods

contentPaddingFor(MREWindowSize size) → EdgeInsetsGeometry
Returns the content padding that fits size.
copyWith({double? fieldBorderRadius, EdgeInsetsGeometry? contentPadding, EdgeInsetsGeometry? expandedContentPadding, double? compactBreakpoint, double? expandedBreakpoint, MREFieldsStrings? strings}) → MREFieldsTheme
Creates a copy of this theme extension with the given fields replaced by the non-null parameter values.
override
lerp(covariant ThemeExtension<MREFieldsTheme>? other, double t) → MREFieldsTheme
Interpolates numbers and paddings. strings cannot be interpolated, so they switch to other's at the halfway point.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
windowSizeFor(double width) → MREWindowSize
Classifies width against compactBreakpoint and expandedBreakpoint.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

of(BuildContext context) → MREFieldsTheme
Returns the tokens registered on the nearest Theme, or defaults.

Constants

defaultCompactBreakpoint → const double
Default compactBreakpoint in logical pixels.
defaultContentPadding → const EdgeInsetsGeometry
Default contentPadding.
defaultExpandedBreakpoint → const double
Default expandedBreakpoint in logical pixels.
defaultExpandedContentPadding → const EdgeInsetsGeometry
Default expandedContentPadding. Slightly denser than the compact one.
defaultFieldBorderRadius → const double
Default fieldBorderRadius in logical pixels.
defaults → const MREFieldsTheme
Tokens used when the host registers no MREFieldsTheme.