juice_lifecycle 0.1.0 copy "juice_lifecycle: ^0.1.0" to clipboard
juice_lifecycle: ^0.1.0 copied to clipboard

App lifecycle (foreground/background/resume) as a Juice bloc, behind a swappable provider seam.

example/lib/main.dart

import 'package:juice/juice.dart';
import 'package:juice_lifecycle/juice_lifecycle.dart';

import 'demo_lifecycle_provider.dart';
import 'home_screen.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  // Demo provider so transitions show without backgrounding the app. Swap for
  // LifecycleConfig() (default WidgetsLifecycleProvider) in a real app.
  BlocScope.register<LifecycleBloc>(
    () => LifecycleBloc.withConfig(
      LifecycleConfig(provider: DemoLifecycleProvider()),
    ),
    lifecycle: BlocLifecycle.permanent,
  );

  runApp(const DemoApp());
}

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

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

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

App lifecycle (foreground/background/resume) as a Juice bloc, behind a swappable provider seam.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#lifecycle #bloc #state-management #app-state #foreground

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

flutter, juice

More

Packages that depend on juice_lifecycle