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

State & navigation manager for flutter. It allows you to update wisely your states and to navigate easily.

example/lib/main.dart

import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_fx/flutter_fx.dart';

FutureOr<void> main() {
  runZonedGuarded<Future<void>>(() async {
    WidgetsFlutterBinding.ensureInitialized();
    // await ErrorHandler.initialize();
    // await Preferences.initPreferences();
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
    // FlutterError.onError =
    //     (FlutterErrorDetails details) => ErrorHandler.handleError(details);
    runApp(FxApp(
      initialRoute: "/",
      routeBuilder: (route) {
        switch (route) {
          case "main":
            return Scaffold(
              backgroundColor: Colors.red,
            );
          case "/":
          default:
            return const MainPage();
        }
      },
    ));
  }, ((error, stack) {
    // ErrorHandler.handleException(error, stack);
  }));
}

class MainPageController {
  static Fx<String> text = "data".toFx;
  static FxString text2 = "NO DATA".toFx;

  void changeState() {
    text.value = "new data ${Random().nextDouble().toString()}";
    text2.value = "new data ${Random().nextDouble().toString()}";
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          FxBuilder(builder: (fxContext) {
            return Text(MainPageController.text.listen(fxContext));
          }),
          FxBuilder(builder: (fxContext) {
            return Text(MainPageController.text2.listen(fxContext));
          }),
          ElevatedButton(
              onPressed: () {
                FxRouter.goTo("main",
                    arguments: NavigationArguments(
                        transitionDirection: TransitionDirection.bottomToTop));
              },
              child: Text("Change state"))
        ],
      ),
    );
  }
}
3
likes
0
points
149
downloads

Publisher

verified publisheralphacodelabs.de

Weekly Downloads

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

Funding

Consider supporting this project:

buymeacoffee.com

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_fx