sinew_riverpod_providers
Ready Riverpod providers for Sinew's network and storage services, and useNetworkChecker.
The wiring every Riverpod app writes by hand: the configured Dio, the token source, the stores and the connectivity checker, as providers you override only where your app differs.
Features
sinewHttpProvider,tokenSourceProvider,refreshTokenStoreProviderandrefreshCallProviderkeyValueStoreProviderandsecureStoreProvider, andSecureRefreshTokenStoreto keep the refresh token in the secure storenetworkCheckerProvideranduseNetworkCheckerto show connectivity in a widget
Getting started
flutter pub add sinew_riverpod_providers
Setup
Override the two app-specific providers once, and open the secure store before runApp:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final container = ProviderContainer(overrides: [
sinewConfigProvider.overrideWithValue(SinewConfig(baseUrl: 'https://api.example.com/v1/', locale: () => 'en')),
refreshCallProvider.overrideWithValue((token) async => RefreshResult.from(await processApiCall(...))),
]);
await container.read(secureStoreProvider.future);
runApp(UncontrolledProviderScope(container: container, child: const App()));
}
Then API classes take ref.watch(sinewHttpProvider), sign-in calls ref.read(tokenSourceProvider).start(...), and a widget shows connectivity with useNetworkChecker(ref.watch(networkCheckerProvider)).
Security services aren't provided here (this package reaches sinew_security only through sinew_storage); add FutureProvider((ref) => FieldCipher.create()) or Provider((ref) => BiometricVault.create()) in the app.
Related packages
Sinew is one architecture for Flutter and Kotlin, released as a set of packages at one version.
Documentation
- Usage docs: sinew.srctool.com
- API reference: pub.dev/documentation/sinew_riverpod_providers
- Source and issues: srctool/sinew-dart
- Design and decisions: the Guide
License
Apache 2.0, see LICENSE.
Libraries
- sinew_riverpod_providers
- Ready Riverpod providers for Sinew's network and storage services, and
useNetworkChecker.