flutter_fx 0.1.4 copy "flutter_fx: ^0.1.4" to clipboard
flutter_fx: ^0.1.4 copied to clipboard

A set of state & navigation manager for flutter. It allows you to update wisely your states and to navigate easily.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_fx/flutter_fx.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return FxApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      initialRoute: "/",
      routeBuilder: (path) {
        switch (path) {
          case "/":
          default:
            return const MyHomePage(title: 'Flutter Demo Home Page');
        }
      },
    );
  }
}

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

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final FxInt _counter = 0.toFx;

  void _incrementCounter() {
    _counter.value++;
  }

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

Publisher

verified publishercrianpiro.de

Weekly Downloads

A set of state & navigation manager for flutter. It allows you to update wisely your states and to navigate easily.

Homepage
Repository (GitHub)
View/report issues

Topics

#state #navigation #state-manager #navigation-manager #state-management

Documentation

API reference

Funding

Consider supporting this project:

buymeacoffee.com

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on flutter_fx