mirror of
https://github.com/lucavenir/go_router_riverpod.git
synced 2025-08-26 07:21:08 +08:00
Inserted RefreshStream legacy example in its stand alone folder
This commit is contained in:
22
legacy/refresh_stream/lib/auth.dart
Normal file
22
legacy/refresh_stream/lib/auth.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class AuthNotifier extends StateNotifier<bool> {
|
||||
AuthNotifier() : super(false);
|
||||
|
||||
/// This mocks a login attempt with email and password
|
||||
Future<void> login(String email, String password) async {
|
||||
state = await Future.delayed(
|
||||
const Duration(milliseconds: 750),
|
||||
() => true,
|
||||
);
|
||||
}
|
||||
|
||||
/// This mocks a logout action
|
||||
Future<void> logout() async {
|
||||
state = false; // No request is mocked here but I guess we could
|
||||
}
|
||||
}
|
||||
|
||||
final authProvider = StateNotifierProvider<AuthNotifier, bool>((ref) {
|
||||
return AuthNotifier();
|
||||
});
|
Reference in New Issue
Block a user