kashi_core 1.6.0 copy "kashi_core: ^1.6.0" to clipboard
kashi_core: ^1.6.0 copied to clipboard

Flutter client foundation for kashi APIs, a Dio client with typed failures, single-flight token refresh, secure storage, and a Riverpod auth controller.

example/example.md

kashi_core example #

Override kashiConfigProvider with your API's base URL, then use apiClientProvider (a preconfigured [KashiApiClient]) and authControllerProvider (session state) anywhere below it in the tree.

import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:kashi_core/kashi_core.dart';

void main() {
  runApp(
    ProviderScope(
      overrides: [
        kashiConfigProvider.overrideWithValue(
          const KashiConfig(baseUrl: 'https://api.example.com/v1'),
        ),
      ],
      child: const MyApp(),
    ),
  );
}

class MyApp extends ConsumerWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final auth = ref.watch(authControllerProvider);
    return CupertinoApp(
      home: switch (auth.status) {
        AuthStatus.signedIn => const HomeScreen(),
        _ => const CupertinoActivityIndicator(),
      },
    );
  }
}

Call the API directly for one-off requests:

final client = ref.read(apiClientProvider);
try {
  final page = await client.page<Map<String, dynamic>>(
    '/posts',
    const {},
    (json) => json,
  );
  print('fetched ${page.items.length} posts');
} on KashiFailure catch (failure) {
  print('request failed: ${failure.code} ${failure.message}');
}
0
likes
160
points
125
downloads

Documentation

API reference

Publisher

verified publishersoftwareseva.org

Weekly Downloads

Flutter client foundation for kashi APIs, a Dio client with typed failures, single-flight token refresh, secure storage, and a Riverpod auth controller.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

dio, flutter, flutter_riverpod, flutter_secure_storage, go_router

More

Packages that depend on kashi_core