Flutter Sample App Firebase Authentication

ÖZGÜR SALGINCI
2 min readAug 20, 2024

--

This simple article demonstrates how to implement and use Firebase Authentication for related article Mobile Backend Architecture Part 3

flutter create testapp
dependencies:
flutter_test:
sdk: flutter
cupertino_icons: ^1.0.2
firebase_core: ^3.3.0 # add this line

You will need to add these dependencies to your pubspec.yaml file.

dart pub global activate flutterfire_cli

FlutterFire is a set of Flutter plugins which connect your Flutter application to Firebase.

You can learn details from here:
https://firebase.flutter.dev/docs/overview/#initialization

For installing FlutterFire and configuring please visit documentation. I assume that you have already installed Firebase CLI and completed flutterfire configure.

and then you will need to run this command to install dependencies.

flutter pub get

Once you installed them you can launch your app.

Also you will need to add GoogleService-Info.plist or json file to related folders.

You can download source code of the demo application from github :

https://github.com/salginci/flutter_firebase

And then modify your applications main.dart file.

import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}

Ready.

In your login screen you can trigger login.

 var resp=    await auth.signInWithEmailAndPassword(
email: emailController.text,
password: passwordController.text,
);

--

--