add auth, format
This commit is contained in:
@@ -34,7 +34,11 @@ String appVersion(Ref ref) {
|
||||
int pointsMultiplier(Ref ref) {
|
||||
// Can read other providers
|
||||
final userTier = 'diamond'; // This would come from another provider
|
||||
return userTier == 'diamond' ? 3 : userTier == 'platinum' ? 2 : 1;
|
||||
return userTier == 'diamond'
|
||||
? 3
|
||||
: userTier == 'platinum'
|
||||
? 2
|
||||
: 1;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -46,7 +50,7 @@ int pointsMultiplier(Ref ref) {
|
||||
@riverpod
|
||||
Future<String> userData(Ref ref) async {
|
||||
// Simulate API call
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
return 'User Data';
|
||||
}
|
||||
|
||||
@@ -55,7 +59,7 @@ Future<String> userData(Ref ref) async {
|
||||
@riverpod
|
||||
Future<String> userProfile(Ref ref, String userId) async {
|
||||
// Simulate API call with userId
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
return 'Profile for user: $userId';
|
||||
}
|
||||
|
||||
@@ -70,7 +74,7 @@ Future<List<String>> productList(
|
||||
String? searchQuery,
|
||||
}) async {
|
||||
// Simulate API call with parameters
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
||||
return ['Product 1', 'Product 2', 'Product 3'];
|
||||
}
|
||||
|
||||
@@ -82,10 +86,7 @@ Future<List<String>> productList(
|
||||
/// Use this for WebSocket connections, real-time updates, etc.
|
||||
@riverpod
|
||||
Stream<int> timer(Ref ref) {
|
||||
return Stream.periodic(
|
||||
const Duration(seconds: 1),
|
||||
(count) => count,
|
||||
);
|
||||
return Stream.periodic(const Duration(seconds: 1), (count) => count);
|
||||
}
|
||||
|
||||
/// Stream provider with parameters
|
||||
@@ -176,7 +177,7 @@ class UserProfileNotifier extends _$UserProfileNotifier {
|
||||
@override
|
||||
Future<UserProfileData> build() async {
|
||||
// Fetch initial data
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
return UserProfileData(name: 'John Doe', email: 'john@example.com');
|
||||
}
|
||||
|
||||
@@ -225,10 +226,7 @@ class UserProfileData {
|
||||
final String email;
|
||||
|
||||
UserProfileData copyWith({String? name, String? email}) {
|
||||
return UserProfileData(
|
||||
name: name ?? this.name,
|
||||
email: email ?? this.email,
|
||||
);
|
||||
return UserProfileData(name: name ?? this.name, email: email ?? this.email);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user