add auth, format
This commit is contained in:
@@ -95,7 +95,7 @@ Stream<bool> isOnline(Ref ref) {
|
||||
return connectivity.onConnectivityChanged.map((result) {
|
||||
// Online if connected to WiFi or mobile
|
||||
return result.contains(ConnectivityResult.wifi) ||
|
||||
result.contains(ConnectivityResult.mobile);
|
||||
result.contains(ConnectivityResult.mobile);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ final class UserDataProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$userDataHash() => r'3df905d6ea9f81ce7ca8205bd785ad4d4376b399';
|
||||
String _$userDataHash() => r'1b754e931a5d4c202189fcdd3de54815f93aaba2';
|
||||
|
||||
/// Async provider with parameters (Family pattern)
|
||||
/// Parameters are just function parameters - much simpler than before!
|
||||
@@ -248,7 +248,7 @@ final class UserProfileProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$userProfileHash() => r'd42ed517f41ce0dfde58d74b2beb3d8415b81a22';
|
||||
String _$userProfileHash() => r'35cdc3f9117e81c0150399d7015840ed034661d3';
|
||||
|
||||
/// Async provider with parameters (Family pattern)
|
||||
/// Parameters are just function parameters - much simpler than before!
|
||||
@@ -346,7 +346,7 @@ final class ProductListProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$productListHash() => r'aacee7761543692ccd59f0ecd2f290e1a7de203a';
|
||||
String _$productListHash() => r'db1568fb33a3615db0a31265c953d6db62b6535b';
|
||||
|
||||
/// Async provider with multiple parameters
|
||||
/// Named parameters, optional parameters, defaults - all supported!
|
||||
@@ -732,7 +732,7 @@ final class UserProfileNotifierProvider
|
||||
}
|
||||
|
||||
String _$userProfileNotifierHash() =>
|
||||
r'87c9a9277552095a0ed0b768829e2930fa475c7f';
|
||||
r'be7bcbe81f84be6ef50e94f52e0c65b00230291c';
|
||||
|
||||
/// AsyncNotifier for state that requires async initialization
|
||||
/// Perfect for fetching data that can then be modified
|
||||
|
||||
Reference in New Issue
Block a user