computed_flutter 0.1.0 copy "computed_flutter: ^0.1.0" to clipboard
computed_flutter: ^0.1.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),
      ),
    );
  }
}
2
likes
0
pub points
0%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

computed, flutter

More

Packages that depend on computed_flutter