juice_auth_network 0.1.2 copy "juice_auth_network: ^0.1.2" to clipboard
juice_auth_network: ^0.1.2 copied to clipboard

Integration glue between juice_auth and juice_network — wires AuthBloc into FetchBloc for token injection, 401 refresh, and per-user cache isolation.

example/lib/main.dart

import 'package:juice/juice.dart';
import 'package:juice_auth/juice_auth.dart';
import 'package:juice_network/juice_network.dart';
import 'package:juice_storage/juice_storage.dart';

import 'demo_wiring.dart';
import 'home_screen.dart';
import 'profile_bloc.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final storageBloc = StorageBloc(
    config: const StorageConfig(hiveBoxesToOpen: [CacheManager.cacheBoxName]),
  );
  await storageBloc.initialize();

  final blocs = await buildDemo(storageBloc: storageBloc);

  // Register so StatelessJuiceWidget can resolve them.
  BlocScope.register<AuthBloc>(() => blocs.authBloc,
      lifecycle: BlocLifecycle.permanent);
  BlocScope.register<FetchBloc>(() => blocs.fetchBloc,
      lifecycle: BlocLifecycle.permanent);
  BlocScope.register<ProfileBloc>(() => blocs.profileBloc,
      lifecycle: BlocLifecycle.permanent);

  runApp(const DemoApp());
}

class DemoApp extends StatelessWidget {
  const DemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'juice_auth_network demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: HomeScreen(),
    );
  }
}
0
likes
160
points
234
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Integration glue between juice_auth and juice_network — wires AuthBloc into FetchBloc for token injection, 401 refresh, and per-user cache isolation.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#authentication #network #bloc #http #integration

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

flutter, juice, juice_auth, juice_network

More

Packages that depend on juice_auth_network