bolter_flutter 7.0.3 copy "bolter_flutter: ^7.0.3" to clipboard
bolter_flutter: ^7.0.3 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(
      debugShowCheckedModeBanner: false,
      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 Scaffold(
      appBar: AppBar(
        title: const Text('Bolter Flutter Example'),
      ),
      body: GridView.builder(
        itemCount: size,
        addRepaintBoundaries: false,
        addAutomaticKeepAlives: false,
        addSemanticIndexes: false,
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 20),
        itemBuilder: (_, index) {
          return BolterBuilder(
            getter: () => presenter.updates[index],
            builder: (_, val) => ColoredBox(
              color: Colors.cyan,
              child: Text(
                val.toString(),
                style: const TextStyle(color: Colors.white),
              ),
            ),
          );
        },
      ),
    );
  }
}
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