flutter_pod 0.18.0 copy "flutter_pod: ^0.18.0" to clipboard
flutter_pod: ^0.18.0 copied to clipboard

A dependency injection and state management library, fast, simple and composable inspired by Riverpod and Jōtai.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_pod/flutter_pod.dart';

// A Counter example implemented with pod

void main() {
  runApp(
    // Adding PodScope enables Pod for the entire project
    const PodScope(child: MyApp()),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: Home());
  }
}

/// Pods are declared globally and specify how to create a state
final counterPod = statePod(0);

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

  @override
  Widget build(BuildContext context) {
    // The watch method is a utility to read and listen a pod
    final count = context.watch(counterPod);

    return Scaffold(
      appBar: AppBar(title: const Text('Counter example')),
      body: Center(
        child: Text('$count'),
      ),
      floatingActionButton: FloatingActionButton(
        // The update and set methods are utilities to change the pod's value
        onPressed: () => context.set(counterPod, 50),
        child: const Icon(Icons.add),
      ),
    );
  }
}
8
likes
160
pub points
27%
popularity

Publisher

verified publishereronsoft.com

A dependency injection and state management library, fast, simple and composable inspired by Riverpod and Jōtai.

Homepage
Repository (GitHub)
View/report issues

Topics

#riverpod #pod #atom #dependency-injection #state-management

Documentation

API reference

License

MIT (license)

Dependencies

flutter, pod

More

Packages that depend on flutter_pod