get_hooked 0.5.4 copy "get_hooked: ^0.5.4" to clipboard
get_hooked: ^0.5.4 copied to clipboard

State management with Listenables and Hooks! Inspired by hooks_riverpod and get_it.

example/lib/main.dart

import 'package:example/benchmark/benchmark.dart';
import 'package:example/counter/counter.dart';
import 'package:example/custom_button/custom_button.dart';
import 'package:example/form/form.dart';
import 'package:example/ref_layout/ref_layout.dart';
import 'package:flutter/material.dart';
import 'package:get_hooked/get_hooked.dart';

void main() => runApp(const App());

enum Screen {
  counter,
  form,
  benchmark,
  button,
  refLayout;

  static final current = Get.it(counter);
}

class App extends RefWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return switch (ref.watch(Screen.current)) {
      Screen.counter => const Counter(),
      Screen.form => const FormExampleApp(),
      Screen.benchmark => const BenchmarkApp(),
      Screen.button => const CustomButtonApp(),
      Screen.refLayout => const RefLayoutApp(),
    };
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        children: [
          for (final screen in Screen.values)
            ListTile(
              title: Text(screen.name),
              onTap: () {
                Screen.current.value = screen;
                Scaffold.maybeOf(context)?.closeDrawer();
              },
            ),
        ],
      ),
    );
  }
}
0
likes
150
points
140
downloads

Documentation

API reference

Publisher

verified publisherno-tolls.dev

Weekly Downloads

State management with Listenables and Hooks! Inspired by hooks_riverpod and get_it.

Homepage
Repository (GitHub)
View/report issues

Topics

#flutter #animation #state-management

License

MIT (license)

Dependencies

collection, collection_notifiers, flutter, meta

More

Packages that depend on get_hooked