frost 2.0.0 copy "frost: ^2.0.0" to clipboard
frost: ^2.0.0 copied to clipboard

State management solution that decouples business logic from UI effortlessly. Frost uses reactive Properties, Watchers, and Signals with minimal boilerplate.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:frost/signal.dart';
import 'package:frost/watcher.dart';
import 'package:frost/store.dart';
import 'model.dart';

Slot doSomething() {
  if (kDebugMode) {
    print('doing something');
  }
}

void main() {
  Store.add(() => CountModel());
  connect(CountModel.countChanged, doSomething);
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key, required this.title});
  final String title;


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Watcher(
              signal: CountModel.countChanged,
              watch: (context) => Text(
                Store.get<CountModel>()!.count.toString(),
                style: Theme.of(context).textTheme.headlineMedium,
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => Store.get<CountModel>()?.incrementCount(),
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
2
likes
160
points
43
downloads

Documentation

API reference

Publisher

verified publishertantalising.tech

Weekly Downloads

State management solution that decouples business logic from UI effortlessly. Frost uses reactive Properties, Watchers, and Signals with minimal boilerplate.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on frost