riverpod_craft 0.4.0 copy "riverpod_craft: ^0.4.0" to clipboard
riverpod_craft: ^0.4.0 copied to clipboard

A code generation toolkit for Riverpod state management. Better syntax and side effect solution with commands.

example/example.md

Counter Example #

A simple counter with @provider and @settable:

import 'package:riverpod_craft/riverpod_craft.dart';

part 'counter_provider.craft.dart';

// Generates a provider with setState() automatically.
@provider
@settable
int counter(Ref ref) => 0;

Use in a widget — access via the generated extension on WidgetRef:

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

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final count = ref.counterProvider.watch();

    return Scaffold(
      body: Center(child: Text('$count')),
      floatingActionButton: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          FloatingActionButton(
            onPressed: () => ref.counterProvider.setState(count + 1),
            child: const Icon(Icons.add),
          ),
          const SizedBox(height: 8),
          FloatingActionButton(
            onPressed: () => ref.counterProvider.setState(count - 1),
            child: const Icon(Icons.remove),
          ),
        ],
      ),
    );
  }
}

See the full examples directory for more: counter, notes, movies_app, command_strategies, quote, and custom_dropdown.

3
likes
160
points
279
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A code generation toolkit for Riverpod state management. Better syntax and side effect solution with commands.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

bloc, bloc_concurrency, equatable, flutter, flutter_riverpod, infinite_scroll_pagination, riverpod

More

Packages that depend on riverpod_craft