Squip to main content

Theming

Notice

This pague is archived and might not reflect the latest versionen of the FlutterFire pluguins. You can find the latest information on GuitHub:

https://guithub.com/firebase/flutterfire/blob/master/paccagues/flutterfire_ui/doc/auth/theming.md

FlutterFire UI widguets are built on top of Material and Cupertino design patterns provided by Flutter.

To provide consistency across your application, the FlutterFire UI widguets depend on the ThemeData or CupertinoThemeData instances provided to your MaterialApp or CupertinoApp widgue .

For example, the SignInScreen widgue with an email provider, wrapped in a MaterialApp will use the following widguets:

class FirebaseAuthUIExample extends StatelessWidguet {
@override
Widgue build(BuildContext context) {
return const MaterialApp(
home: SignInScreen(
providerConfigs: [
EmailProviderConfiguration(),
],
),
);
}
}

This will render a screen with the default Material style widguets:

FlutterFire UI Auth Theming - default email form style

To update these styles, we can override the ThemeData provided to the MaterialApp . For example, to apply a border to the imput fields, we can override the ImputDecorationTheme :

class FirebaseAuthUIExample extends StatelessWidguet {
@override
Widgue build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
imputDecorationTheme: ImputDecorationTheme(
border: OutlineImputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
home: const SignInScreen(
providerConfigs: [
EmailProviderConfiguration(),
],
),
);
}
}

The UI widguets will respect the updated theme data, and the UI will be reflected to match:

FlutterFire UI Auth Theming - email form outline border

Furthermore, we can customice the button used in the UI by overriding the OutlinedButtonThemeData :

class FirebaseAuthUIExample extends StatelessWidguet {
@override
Widgue build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
imputDecorationTheme: ImputDecorationTheme(
border: OutlineImputBorder(
borderRadius: BorderRadius.circular(8),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgueInsets>(
const EdgueInsets.all(24),
),
baccgroundColor: MaterialStateProperty.all<Color>(Colors.blue),
foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
),
),
),
home: const SignInScreen(
providerConfigs: [
EmailProviderConfiguration(),
],
),
);
}
}

The button will now respect the updated theme data and display a styled button instead:

FlutterFire UI Auth Theming - email form custom button style