oncecall 0.0.2 copy "oncecall: ^0.0.2" to clipboard
oncecall: ^0.0.2 copied to clipboard

Oncecall is a memoization tool for use in the build method of Widgets.

example/main.dart

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

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

int counter = 0;

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

  @override
  Widget build(BuildContext context) {
    final value = oncecall(context, () => ++counter);

    return MaterialApp(
      home: Scaffold(
        body: Center(
          // It is always "Count: 1" because it is memoized.
          child: Text('Count: $value'),
        ),
      ),
    );
  }
}
1
likes
150
pub points
0%
popularity

Publisher

verified publisherodroe.dev

Oncecall is a memoization tool for use in the build method of Widgets.

Homepage
Repository (GitHub)
View/report issues

Topics

#once #call #memo

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

_octr, flutter

More

Packages that depend on oncecall