trent 0.0.1 copy "trent: ^0.0.1" to clipboard
trent: ^0.0.1 copied to clipboard

A Flutter package for simple, scalable, and reactive state management with built-in dependency injection and efficient stream-based state handling.

example/lib/main.dart

import 'package:example/test_trent.dart';
import 'package:flutter/material.dart';
import 'package:trent/trent.dart';

void main() {
  TrentManager([AuthTrent()]).init();
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'example',
      home: Scaffold(
        body: Center(
          child: Alerter<AuthTrent, TestTrentTypes>(
            handlers: (mapper) => mapper
              ..all((state) {
                print("Alert received");
              })
              ..as<A>((state) {
                print("Alert received of type A");
              })
              ..as<B>((state) {
                print("Alert received of type B");
              })
              ..as<C>((_) {
                print("Alert received of type C");
              }),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Digester<AuthTrent, TestTrentTypes>(
                  handlers: (mapper) {
                    // get<AuthTrent>().currState = // show this example directly
                    mapper
                      ..all((state) => const Text("All states"))
                      ..as<A>((state) => Text('State A with value: ${state.value}'))
                      ..as<B>((state) => const Text('State B'))
                      ..as<C>((state) => const Text('State C'));
                  },
                ),
                SizedBox(height: 20),
                TextButton(
                  onPressed: () => get<AuthTrent>().testBizFunc1(),
                  child: const Text("test biz func 1"),
                ),
                TextButton(
                  onPressed: () => get<AuthTrent>().testBizFunc2(),
                  child: const Text("test biz func 2"),
                ),
                TextButton(
                  onPressed: () => get<AuthTrent>().testBizFunc3(),
                  child: const Text("test biz func 3"),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
copied to clipboard
3
likes
0
points
78
downloads

Publisher

verified publishermatthewtrent.me

Weekly Downloads

2024.09.16 - 2025.03.31

A Flutter package for simple, scalable, and reactive state management with built-in dependency injection and efficient stream-based state handling.

Homepage
Repository (GitHub)
View/report issues

Topics

#trent #state-management #dependency-injection #stream-based-state

License

unknown (license)

Dependencies

equatable, flutter, get_it, rxdart

More

Packages that depend on trent