Beginning FlutterFire

Aug 30 2022 · Dart 2.16, Flutter 3.0, Visual Studio Code 1.69

Part 2: Add Authentication to Your App

07. Customize Your Labels

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 06. Add a Forgot Password Screen Next episode: 08. What's the Cloud Firestore?

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Transcript: 07. Customize Your Labels

There are cases where you might need to change the textField labels of the sign in and sign up screens: this may happen when your app’s language is not English, or when you simply want to customize your labels. THe good news is that you can customize every single label in our screen. Let’s see how to do that:

Let’s add a new folder in the lib folder of our project and call it data. Here let’s create a new file, called labels.dart. In this file we’ll set the strings that will override the default labels that flutterfire_ui provides for the text fields. In the file, create a class, and call it LavelOverrides: this must implement DefaultLocalizations.

class LabelOverrides extends DefaultLocalizations { 

 DefaultLocalizations requires an import of the internationalization package, called i10n.dart 

import 'package:flutterfire_ui/i10n.dart'; 

Here, let’s override the emailInputLabel getter. We want to use an informal tone here, so the message will be “gimme your email”. Copy this three times: first let’s set the password input label with “Your password now!”. Then set the signInActionText with “Enter the club!”. The last label that we’ll set is the registerActionText. Just add “Join the club!”

  @override 
  String get emailInputLabel => 'Gimme your email!'; 

  @override 
  String get passwordInputLabel => 'Your password now!'; 

  @override 
  String get signInActionText => 'Enter the club!'; 

  @override 
  String get registerActionText => 'Join the club'; 

Now you have to tell the app that it needs to use these customized, labels instead of the default ones. So, open the main.dart file, and in the build method of myApp, set the localizationDelegates for MaterialApp. Here add FlutterFireUILocalizations.withDefaultOverrides(LabelOverrides()). Of course this will need the import for our LabelOverrides class.

localizationsDelegates: [ 
        FlutterFireUILocalizations.withDefaultOverrides(LabelOverrides()), 
], 

Let’s run the app: as you can see, you’ve completely customized this screen!

So, with very little code, you’ve added sign in and sign-up capabilities to your app. Let’s see how to add a remote database next!