lazy_builder_widget 0.0.1 copy "lazy_builder_widget: ^0.0.1" to clipboard
lazy_builder_widget: ^0.0.1 copied to clipboard

A builder widget that can prevent rebuilding.

A builder widget that can prevent rebuilding.

Caution: Preventing rebuilds is a potentially risky action, so use it judiciously.

Usage #


Widget build(BuildContext context) {
  return LazyBuilderWidget<MediaQueryData>(
    builder: (BuildContext context, MediaQueryData data) {
      return Text('Screen width = ${data.size.width}');
    },
    selector: (BuildContext context) {
      // Return the data used to build
      return MediaQuery.of(context);
    },
    buildWhen: (MediaQueryData prev, MediaQueryData curr) {
      // Do not rebuild when this route is not the top-most route on the navigator
      return ModalRoute.of(context)?.isCurrent ?? true;
    },
  );
}

1
likes
130
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

A builder widget that can prevent rebuilding.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on lazy_builder_widget