Firebase Auth UI — The Hidden Gem Package (Part 2)

Aakash Pamnani
7 min readDec 17, 2023

--

Header Image

In the previous article we know about different firebase UI packages in this article we will dive deep into the firebase_ui_auth package. If you have not read the previous article you can read it here.

Does your authentication screen UI resemble a dull and uninspiring form, leaving your users with a less-than-thrilling first impression of your app? If you find yourself yearning for a sleek and polished authentication interface that not only looks good but also ensures a seamless user experience, then look no further. The solution to your UI lies in the firebase_auth_ui package — a game-changer that transforms authentication screens into visually appealing and user-friendly experiences.

Getting Started: Adding Required Pub Packages

Before we dive into the transformative power of firebase_ui_auth, let’s ensure you have the necessary packages added to your pubspec.yaml file.

dependencies:
flutter:
sdk: flutter
firebase_auth: ^latest_version
firebase_core: ^latest_version
firebase_ui_auth: ^latest_version

Make sure to replace latest_version with the actual version numbers available at the time of your implementation. Now, let’s explore how this package can revolutionize your authentication UI.

The Dilemma of Boring Auth Screens

Boring emotion

Authentication screens are often the first point of interaction between users and your app. Yet, many developers grapple with the challenge of creating an aesthetically pleasing and engaging authentication UI. The default UIs provided by Firebase, while functional, might lack the visual flair that sets your app apart.

Consider the scenario: a bland email and password input form or a generic Google Sign-In button that fails to captivate users. In a world where first impressions matter, a lackluster authentication screen could potentially turn away users before they even experience the brilliance of your app.

Enter firebase_ui_auth

The firebase_ui_auth package comes to the rescue, offering a set of pre-built UI components that inject life and style into your authentication screens. With just a few lines of code, you can transform your authentication UI from boring to magnificent, providing users with a delightful onboarding experience.

Effortless Integration

One of the standout features of firebase_ui_auth is its simplicity of integration. You no longer need to spend hours crafting custom authentication screens or wrestling with Firebase Authentication code. The package seamlessly integrates with Firebase Authentication, making the process painless and efficient.

FirebaseUIAuth.configureProviders([
EmailAuthProvider(),
PhoneAuthProvider(),
GoogleProvider(clientId: ""),
AppleProvider(),
TwitterProvider(apiKey: "", apiSecretKey: ""),
FacebookProvider(clientId: ""),
]);

This snippet of code alone is enough to launch a beautifully crafted authentication screen with Phone, e-mail, Google Sign-In and other options.

Aesthetic Consistency

Consistency in UI design is key to a positive user experience. firebase_ui_auth ensures that your authentication screen maintains a cohesive look and feel throughout various authentication methods. Whether users choose email/password authentication or opt for the simplicity of Google Sign-In, the transition is seamless, presenting a polished and professional interface.

Screens

This package offers two distinct types of screens, each designed to enhance the user authentication experience. The primary screen serves as the central hub for signing in, featuring buttons corresponding to the various authentication providers (such as Phone and Google Sign-In) added at the initialization of the app. These buttons act as gateways, leading users to dedicated screens tailored to each specific authentication method.

Upon selecting a particular authentication provider, users are seamlessly directed to a dedicated screen designed exclusively for that method. For instance, choosing the Phone authentication option triggers the display of a phone number and OTP screen, while selecting the email option seamlessly transitions users to an email and password input screen. This thoughtful design ensures a streamlined and intuitive user journey, enhancing both the functionality and aesthetics of your authentication process.

SignInScreen(); //just add this widget to your app.
// and everything will be handeled by the package 😎.
Main SignIn Screen
Phone Number Screen
Rest email screen

Profile Screen

Within this package, a feature-rich Profile Screen awaits, providing users with comprehensive details about their logged-in status. Users can view their name, profile image, and the authentication provider through which they logged in. Moreover, the Profile Screen includes a seamless account linking feature, allowing users to connect their account with various providers for added flexibility.

To effortlessly integrate the Profile Screen into your application, simply add the ProfileScreen widget to your widget tree. The beauty of this screen lies not only in its functionality but also in the plethora of customization options it offers. Tailor the Profile Screen to fit seamlessly into your app's design, providing users with a personalized and engaging experience. Elevate the user interface of your application by incorporating the Profile Screen, a versatile component within this dynamic package.

Profile Screen

Examples in Action

We will see the examples of two main auth providers Phone and Google Sign-in, You can explore and learn about other methods like email/password, Facebook, Twitter etc from the official docs here.

Phone Authentication

To integrate Phone Authentication seamlessly, begin by adding the PhoneAuthProvider to the list of providers, as mentioned earlier.

// Add PhoneAuthProvider to the provider list
final List<AuthProvider> providers = [
// … other providers
AuthProvider.phone(),
];

// Listen to user stream changes provided by Firebase Auth
return MaterialApp(
initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile',
routes: {
'/sign-in': (context) => SignInScreen(providers: providers),
'/profile': (context) => ProfileScreen(providers: providers),
},
);

Now, you have two options for handling phone authentication:

1. Let the Package Handle the UI:
If you prefer a hands-off approach, let the package take care of everything. Relax and watch as the package seamlessly manages the user interface. This option is perfect if you want a quick and efficient solution without delving into UI customization.

2. Customize the UI:
Should you desire a more aesthetically pleasing UI, this package provides widgets like PhoneInputScreen, SMSCodeInputScreen, PhoneInput, and SMSCodeInput. Incorporate these widgets into your application to enhance the visual appeal. For further details on customization, refer to the documentation .

2. Google Sign-In

Similar to Phone Authentication, Google Sign-In offers two options for integration:

1. Utilize the Built-In Google Sign-In Button:
Easily integrate the Google Sign-In button provided in the main SignInScreen by adding the Google provider to your list.

2. Customize the Google Sign-In Button:
For a more tailored approach, consider adding the Google Sign-In button to your custom screen using widgets like GoogleSignInButton or GoogleSignInIconButton. This flexibility allows you to seamlessly incorporate Google Sign-In into your app while maintaining control over the UI.

With these options at your disposal, you can choose the approach that best suits your project’s requirements. Whether you opt for simplicity or crave a customized UI, this package empowers you to implement both Phone Authentication and Google Sign-In effortlessly.

Elevating User Experience

Beyond the visual appeal, firebase_ui_auth contributes to an enhanced user experience. By simplifying the authentication process and providing an interface familiar to users, it reduces friction during onboarding. Users are more likely to engage positively with an app that not only functions well but also presents a visually pleasing and intuitive authentication experience.

Conclusion

In the competitive landscape of mobile app development, where user experience reigns supreme, the firebase_auth_ui package emerges as a hidden gem. Elevate your authentication UI from mundane to extraordinary, leaving a lasting impression on users right from the moment they create an account or sign in. Say goodbye to boring authentication screens and embrace the power of firebase_auth_ui to craft an engaging and visually stunning onboarding experience for your users. Give it a try and watch as your app’s first impression becomes a memorable one.

Happy coding! 😀

I hope you found this article enjoyable! If you appreciated the information provided, you have the option to support me by Buying Me A Coffee! Your gesture would be greatly appreciated!

Follow Me

Thank you for taking the time to read this article. If you enjoyed it, feel free to explore more of my articles and consider following me for future updates. Your support is greatly appreciated!

https://www.linkedin.com/in/aakashpamnani/

https://twitter.com/Aakash_P_

Thank you for taking the time to read this article. If you enjoyed it, feel free to explore more of my articles and consider following me for future updates. Your support is greatly appreciated!

--

--

Aakash Pamnani

Flutter, Java, developer. | Trying to explain concepts in the most straightforward way possible.