nonso 0.0.23
nonso: ^0.0.23 copied to clipboard
A package that handles email and password authentication in a Flutter app. It is based on Firebase Authentication.
Implement email and password authentication in your app by inserting ONE widget from this package in your widget tree.
It is based on Firebase Authentication and Bloc.
Features #
- Register user accounts using email and password authentication.
- Send and resend verification emails to confirm email addresses.
- Sign in users with email and password.
- Sign out users.
- Handle password reset scenarios.
Usage #
- Add Firebase to your Flutter app.
- Install the
firebase_auth
plugin. - Install the
flutter_bloc
package. - Install this package!
- Pass your widget to the
AuthScreen
constructor as a descendat of a widget that can provide aAuthBloc
instance, likeBlocBrovider<AuthBloc>
.
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:nonso/nonso.dart' as nonso;
class MyApp extends StatelessWidget {
final FirebaseAuth firebaseAuthInstance;
const MyApp(this.firebaseAuthInstance, {super.key});
@override
Widget build(BuildContext context) {
return BlocProvider<nonso.AuthBloc>(
create: (context) => nonso.AuthBloc(firebaseAuthInstance),
child: MaterialApp(
title: 'Flutter Demo',
localizationsDelegates: [nonso.AppLocalizations.delegate],
supportedLocales: nonso.AppLocalizations.supportedLocales,
home: nonso.AuthScreen(
// This is your home screen
const YourHomePage(title: 'Flutter Demo Home Page'),
),
),
);
}
}
- Use
context.read<AuthBloc>().state.user!
to get information about the signed in user.
import 'package:firebase_auth/firebase_auth.dart';
Widget build(BuildContext context) {
final User currentSignedInUser = context.read<AuthBloc>().state.user!;
return Text("${currentSignedInUser.uid}");
}