Skip to content

Commit

Permalink
Convert AccountScreenController and EmailPasswordSignInController to …
Browse files Browse the repository at this point in the history
…use Riverpod Generator
  • Loading branch information
bizz84 committed Aug 25, 2023
1 parent 259fda8 commit 0502e92
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'dart:async';

import 'package:ecommerce_app/src/features/authentication/data/fake_auth_repository.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

class AccountScreenController extends AutoDisposeAsyncNotifier<void> {
part 'account_screen_controller.g.dart';

@riverpod
class AccountScreenController extends _$AccountScreenController {
@override
FutureOr<void> build() {
// nothing to do
Expand All @@ -14,7 +17,3 @@ class AccountScreenController extends AutoDisposeAsyncNotifier<void> {
state = await AsyncValue.guard(() => authRepository.signOut());
}
}

final accountScreenControllerProvider =
AutoDisposeAsyncNotifierProvider<AccountScreenController, void>(
AccountScreenController.new);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import 'dart:async';

import 'package:ecommerce_app/src/features/authentication/data/fake_auth_repository.dart';
import 'package:ecommerce_app/src/features/authentication/presentation/sign_in/email_password_sign_in_form_type.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

class EmailPasswordSignInController extends StateNotifier<AsyncValue<void>> {
EmailPasswordSignInController(this.ref) : super(const AsyncData<void>(null));
final Ref ref;
part 'email_password_sign_in_controller.g.dart';

@riverpod
class EmailPasswordSignInController extends _$EmailPasswordSignInController {
@override
FutureOr<void> build() {
// nothing to do
}
Future<bool> submit(
{required String email,
required String password,
Expand All @@ -27,8 +33,3 @@ class EmailPasswordSignInController extends StateNotifier<AsyncValue<void>> {
}
}
}

final emailPasswordSignInControllerProvider = StateNotifierProvider.autoDispose<
EmailPasswordSignInController, AsyncValue<void>>((ref) {
return EmailPasswordSignInController(ref);
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0502e92

Please sign in to comment.