sinew_network 1.1.0
sinew_network: ^1.1.0 copied to clipboard
SinewHttp (Dio), the auth layer, processApiCall, retry, polling and NetworkChecker.
sinew_network example #
A complete app that uses this package, with every platform runner, is the repository's
example: a paged list of orders through Sinew's pager, its
Riverpod mixins and Camouflage's CamoPagedList.
Usage #
final config = SinewConfig(
baseUrl: 'https://api.example.com/v1',
locale: () => 'en',
anonymousPaths: {'/auth/login'},
);
final dio = SinewHttp.dio(config, tokenSource);
// In a repository: any failure becomes a typed SinewException.
Future<Result<Order>> cancel(String id) =>
processApiCall('ORD', 'CANCEL', () => api.cancel(id));
API classes use paths relative to baseUrl (get('orders')), since a leading / would replace its own path. On sign-out, call SinewHttp.resetAuth(dio) and tokenSource.clear().