userDataSourceProvider top-level property
final
Provides the current UserDataSource
instance.
Implementation
final userDataSourceProvider = Provider<UserDataSource>((ref) {
final token = ref.watch(userTokenProvider);
final apiService = ref.watch(apiServiceProvider);
return token.when(
data: (token) => StdUserDataSource(apiService, token),
loading: () => TokenUnavailableUserDataSource(reason: "Token is loading"),
error: (error, stackTrace) => TokenUnavailableUserDataSource(
reason: "User is not logged in",
error: error,
stackTrace: stackTrace,
),
);
});