bolter_flutter 7.0.2 copy "bolter_flutter: ^7.0.2" to clipboard
bolter_flutter: ^7.0.2 copied to clipboard

discontinuedreplaced by: bolter

based on bolter library extensions for manage widgets updates

example/lib/main.dart

import 'dart:async';
import 'dart:math';

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

void main() {
  // kProfileBolterPerformanceLogging = true;
  runApp(
    MaterialApp(
      showPerformanceOverlay: true,
      home: PresenterProvider(
        presenter: ExamplePresenter(),
        child: const Example(),
      ),
    ),
  );
}

const size = 10000000;

class ExamplePresenter extends Presenter<ExamplePresenter> {
  final updates = List.generate(size, (index) => index, growable: false);
  late final rnd = Random();

  void refresh() {
    final v = rnd.nextInt(10);
    perform(
      action: () {
        final t = DateTime.now();
        for (var index = 0; index < updates.length; index++) {
          updates[index] = v;
        }
        // print(DateTime.now().difference(t).inMilliseconds);
      },
    );
  }
}

class Example extends StatefulWidget {
  const Example({Key? key}) : super(key: key);

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  late final presenter = context.presenter<ExamplePresenter>();

  @override
  void initState() {
    Timer.periodic(const Duration(milliseconds: 200), (timer) {
      presenter.refresh();
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Stack(
        alignment: Alignment.bottomCenter,
        children: [
          GridView.builder(
            itemCount: size,
            addRepaintBoundaries: false,
            addAutomaticKeepAlives: false,
            addSemanticIndexes: false,
            gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 20),
            itemBuilder: (_, index) {
              return SyncBuilder(
                getter: () => presenter.updates[index],
                builder: (_, val) => ColoredBox(
                  child: Text(val.toString()),
                  color: Colors.cyan,
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}
4
likes
0
pub points
0%
popularity

Publisher

verified publisherrenesanse.net

based on bolter library extensions for manage widgets updates

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

bolter, flutter

More

Packages that depend on bolter_flutter