Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
refactor: Update login.dart to use authNotifier instead of ref.read(a…
Browse files Browse the repository at this point in the history
…uthProvider.notifier)
  • Loading branch information
xuelink committed Jun 28, 2024
1 parent 1b8e513 commit f213f31
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions lib/pages/login/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class LoginScreenState extends ConsumerState<LoginScreen> {
Widget build(BuildContext context) {
Brightness platformBrightness = MediaQuery.of(context).platformBrightness;

final authNotifier = ref.read(authProvider.notifier);

return Scaffold(
body: SafeArea(
child: Center(
Expand Down Expand Up @@ -60,11 +62,11 @@ class LoginScreenState extends ConsumerState<LoginScreen> {
dButton(
text: "Login",
onPress: () async {
await ref.read(authProvider.notifier).login(
email: emailController.text,
password: passwordController.text,
context: context,
);
await authNotifier.login(
email: emailController.text,
password: passwordController.text,
context: context,
);
},
),
const SizedBox(height: 16),
Expand Down Expand Up @@ -92,10 +94,10 @@ class LoginScreenState extends ConsumerState<LoginScreen> {
height: 40,
),
onPressed: () async {
await ref.read(authProvider.notifier).oAuthLogin(
provider: OAuthProvider.google,
context: context,
);
await authNotifier.oAuthLogin(
provider: OAuthProvider.google,
context: context,
);
},
),
const SizedBox(width: 30),
Expand All @@ -106,21 +108,21 @@ class LoginScreenState extends ConsumerState<LoginScreen> {
height: 40,
),
onPressed: () async {
await ref.read(authProvider.notifier).oAuthLogin(
provider: OAuthProvider.facebook,
context: context,
);
await authNotifier.oAuthLogin(
provider: OAuthProvider.facebook,
context: context,
);
},
),
const SizedBox(width: 30),
IconButton(
icon: SvgPicture.asset('assets/images/apple_icon.svg',
width: 40, height: 40),
onPressed: () async {
await ref.read(authProvider.notifier).oAuthLogin(
provider: OAuthProvider.apple,
context: context,
);
await authNotifier.oAuthLogin(
provider: OAuthProvider.apple,
context: context,
);
},
),
],
Expand Down

0 comments on commit f213f31

Please sign in to comment.