should_rebuild 0.1.2

ShouldRebuild #

Star this Repo pub package License GitHub issues GitHub forks

A widget can prevent Child Widget unnecessary rebuild.You can filter whether you need rebuild based on whether the property values received by the old Child Widget and the new Child Widget are equal.

(这个widget可以防止它的child发生不必要的rebuild,你可以判断新的Child Widget和旧的Child Widget接收的属性值是否相等来过滤是否需要rebuild)

Add dependency #

dependencies:
  should_rebuild: 0.1.2

Or

dependencies:
  should_rebuild:
      git:
        url: https://github.com/fluttercandies/should_rebuild

Super simple to use #

ShouldRebuild<Todo>(
    shouldRebuild: (oldWidget, newWidget) => oldWidget.counter != newWidget.counter,
    child: Todo(counter: counter,)
),

Todo Widget

class Todo extends StatelessWidget {
  final int counter;
  Todo({this.counter});
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Text(counter.toString()),
    );
  }
}

The Todo widget only rebuild if counter changes

ShouldRebuild Widget is a generic StatefulWidget,this generic represents the type of Widget returned by the builder method

Changelog #

[0.1.2]

  • change assert

[0.1.1]

  • add analysis_options.ymal

Version 0.0.1 (2019-09-02) #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  should_rebuild: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:should_rebuild/should_rebuild.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Sep 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/should_rebuild.dart.

Run flutter format to format lib/should_rebuild.dart.

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and should_rebuild.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test