Skip to content

Override component defaults

Use component theme data for repeated product decisions. Use widget properties for a single instance and a local DievasTheme for a scoped variation.

Start from a complete default theme, copy its input settings, then provide the updated component theme:

class RoundedInputsApp extends StatelessWidget {
const RoundedInputsApp({super.key});
@override
Widget build(BuildContext context) {
final base = DievasLightThemeData();
final components = base.components.copyWith(
textInput: base.components.textInput.copyWith(
borderRadius: BorderRadius.circular(16),
),
);
return DievasScope(
themeMode: ThemeMode.light,
lightTheme: base.copyWith(components: components),
builder: (context, theme, child) => MaterialApp(
theme: theme.material,
home: const Scaffold(body: DievasTextInput(label: 'Name')),
),
);
}
}

This example intentionally forces light mode. For a product supporting dark mode, derive the override separately from the dark base so text and surfaces retain appropriate contrast.

Wrap a subtree with DievasTheme(data: yourTheme, child: yourContent) when one region needs a different Dievas theme. If that region also contains Material widgets, supply a matching Flutter Theme using the same theme’s material value.

Do not copy light component data wholesale into a dark theme. Explicit component overrides take responsibility for the values they supply.

Requirement Place the decision
One instance Supported widget property
One region Local theme wrapper
Every instance in a product Application component theme
Default for all consumers Dievas library change with documentation and migration review

Compare the default and overridden component. Check disabled, focused, error, light, and dark states affected by the change.

Choose components or build a form.