computed_flutter 0.2.0 copy "computed_flutter: ^0.2.0" to clipboard
computed_flutter: ^0.2.0 copied to clipboard

Straightforward, reliable, performant and testable reactive state management for Flutter

example/main.dart

import 'package:computed_flutter/computed_flutter.dart';

import 'package:flutter/material.dart';

final count = ValueNotifier(0);

void main() {
  runApp(const MyApp());
}

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

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

// Note that unlike the vanilla counter app, this widget is stateless
class MyHomePage extends ComputedWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Computed Flutter Demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text('${count.use}',
                style: Theme.of(context).textTheme.headlineMedium)
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => count.value++,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
3
likes
150
points
54
downloads

Publisher

unverified uploader

Weekly Downloads

Straightforward, reliable, performant and testable reactive state management for Flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

computed, flutter

More

Packages that depend on computed_flutter