This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
flow_builder: ^0.0.6 | |
flutter_bloc: ^7.3.0 | |
freezed_annotation: ^1.1.0 | |
dev_dependencies: | |
freezed: ^1.1.1 | |
build_runner: ^2.1.7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'auth_cubit.dart'; | |
class AuthState extends Equatable { | |
const AuthState({required this.isSignedIn}); | |
final bool isSignedIn; | |
@override | |
List<Object> get props => [isSignedIn]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'auth_cubit.dart'; | |
@freezed | |
class AuthState with _$AuthState { | |
const factory AuthState.initial({required bool isSignedIn}) = _Initial; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'auth_cubit.dart'; | |
@freezed | |
class AuthState with _$AuthState { | |
const factory AuthState.initial({required bool isSignedIn}) = _Initial; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// coverage:ignore-file | |
// GENERATED CODE - DO NOT MODIFY BY HAND | |
// ignore_for_file: type=lint | |
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target | |
part of 'auth_cubit.dart'; | |
// ************************************************************************** | |
// FreezedGenerator | |
// ************************************************************************** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'login_cubit.dart'; | |
@freezed | |
class LoginState with _$LoginState { | |
const factory LoginState.initial( | |
{@Default(Email.pure()) Email email, | |
@Default(Password.pure()) Password password, | |
@Default(FormzStatus) FormzStatus status, | |
@Default('') String exceptionError}) = _Initial; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'login_cubit.dart'; | |
class LoginState extends Equatable { | |
const LoginState({ | |
this.email = const Email.pure(), | |
this.password = const Password.pure(), | |
this.status = FormzStatus.pure, | |
this.exceptionError = "", | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'sign_up_cubit.dart'; | |
@freezed | |
class SignUpState with _$SignUpState { | |
const factory SignUpState.initial() = _Initial; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthCubit extends Cubit<AuthState> { | |
AuthCubit() : super(const AuthState.initial(isSignedIn: false)) { | |
FirebaseAuth.instance.authStateChanges().listen((User? user) { | |
if (user == null) { | |
return emit(state.copyWith(isSignedIn: false)); | |
} else { | |
emit(state.copyWith(isSignedIn: true)); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LandingPage extends StatelessWidget { | |
const LandingPage({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return FlowBuilder<AuthState>( | |
state: context.select((AuthCubit cubit) => cubit.state), | |
onGeneratePages: (authState, pages) { | |
if (authState.isSignedIn) { | |
return [HomePage.page()]; |
OlderNewer