flutter_compute_tree 1.0.0+9 copy "flutter_compute_tree: ^1.0.0+9" to clipboard
flutter_compute_tree: ^1.0.0+9 copied to clipboard

Easy way to bind your data to Flutter widgets

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_compute_tree/flutter_compute_tree.dart';
import 'package:flutter_compute_tree_example/ref_action.dart';
import 'package:flutter_compute_tree_example/trigger_handler.dart';

import 'async_handler_trigger.dart';
import 'invoke.dart';
import 'invoke_async.dart';
import 'memo.dart';
import 'ref.dart';

void main() {
  const apps = [
    RefApp(),
    InvokeApp(),
    InvokeAsyncApp(),
    AsyncHandlerTriggerApp(),
    MemoApp(),
    TriggerHandlerApp(),
    RefActionApp(),
  ];

  runApp(const App(apps: apps));
}

class App extends StatelessWidget {
  final List<Widget> apps;

  const App({super.key, required this.apps});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: NodeBuilder((ctNode) {
        final selectedAppIndex = ref(() => 0);
        final app = apps[selectedAppIndex.value];

        return Scaffold(
          appBar: AppBar(
            title: Text(app.toStringShort()),
          ),
          body: Center(
            child: PlatformMenuBar(
              menus: [
                const PlatformMenu(
                  label: 'Context tree',
                  menus: [],
                ),
                PlatformMenu(
                  label: 'Apps',
                  menus: [
                    PlatformMenuItemGroup(
                      members: [
                        for (int i = 0; i < apps.length; i++)
                          PlatformMenuItem(
                            label:
                                apps[i].toStringShort().replaceAll('App', ''),
                            onSelected: () => selectedAppIndex.value = i,
                          )
                      ],
                    )
                  ],
                )
              ],
              child: app,
            ),
          ),
        );
      }),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Easy way to bind your data to Flutter widgets

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, matches

More

Packages that depend on flutter_compute_tree