sinew_riverpod_providers

pub package License Docs

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, refreshTokenStoreProvider and refreshCallProvider
  • keyValueStoreProvider and secureStoreProvider, and SecureRefreshTokenStore to keep the refresh token in the secure store
  • networkCheckerProvider and useNetworkChecker to 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.

Sinew is one architecture for Flutter and Kotlin, released as a set of packages at one version.

Documentation

License

Apache 2.0, see LICENSE.

Libraries

sinew_riverpod_providers
Ready Riverpod providers for Sinew's network and storage services, and useNetworkChecker.