binding_helper 0.0.1

  • Example
  • Installing
  • Versions
  • 43


Helper for WidgetsBinding.It is a easy way to use WidgetsBinding, for example: Get the size of a widget after the widget is rendered.

Getting Started




to your pubspec.yaml

Get the size of the widget

Using GetRectMinxin

class MyState extends State<MyWidget> width GetRectMinxin<MyWidget>{

    // The rect includs size and position of the widget
    void onGetRect(Rect rect) { code


Using RectProvider

 new RectProvider(child: myWidget,onGetRect: (Rect rect){
            /// rect is the `Rect` of myWidet
          _rect = rect;


More easy way to use WidgetsBinding is coming soon.

[0.0.1] - [2018.08.30] init project

* Get rect of widgets


import 'package:flutter/material.dart';

import 'dart:math' as Math;

import 'package:binding_helper/binding_helper.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
      home: new MyHomePage(title: 'Flutter Demo Home Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  _MyHomePageState createState() => new _MyHomePageState();

List<Color> colors = [,

typedef void TapRect(Rect rect);

class RectGetter extends StatefulWidget {
  final Widget child;
  final TapRect tapRect;

  RectGetter({this.child, this.tapRect});

  State<StatefulWidget> createState() {
    return new _RectGetterState();

class _RectGetterState extends State<RectGetter> {
  Rect _rect;

  Widget build(BuildContext context) {
    return new GestureDetector(
      onTap: () {
      behavior: HitTestBehavior.opaque,
      child: new RectProvider(
        child: widget.child,
        onGetRect: (Rect rect) {
          _rect = rect;

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey globalKey = new GlobalKey();

  Widget build(BuildContext context) {
    List<Widget> list = [];
    for (int i = 0; i < 100; ++i) {
        new Container(
            color: colors[i % colors.length],
            child: new Padding(
                  new EdgeInsets.all(new Math.Random().nextInt(10).toDouble()),
              child: new RectGetter(
                tapRect: (Rect rect) {
                  ScaffoldState state = globalKey.currentState;

                  state.showSnackBar(new SnackBar(
                      content: new SizedBox(
                    height: 30.0,
                    child: new Text(
                      "The rect is $rect",
                      style: new TextStyle(color: Colors.white),
                child: new SizedBox(
                  height: 30.0 + new Math.Random().nextInt(70).toDouble(),
                  width: 30.0 + new Math.Random().nextInt(70).toDouble(),

    return new Scaffold(
      key: globalKey,
      appBar: new AppBar(
        title: new Text(widget.title),
      body: new Stack(
        children: <Widget>[
          new SingleChildScrollView(
            child: new Wrap(
              children: list,
      ), // This trailing comma makes auto-formatting nicer for build methods.

Use this package as a library

1. Depend on it

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

  binding_helper: ^0.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:binding_helper/binding_helper.dart';
Version Uploaded Documentation Archive
0.0.1 Aug 30, 2018 Go to the documentation of binding_helper 0.0.1 Download binding_helper 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0


Detected platforms:

Error(s) prevent platform classification:

Error(s) in lib/binding_helper.dart: The class 'GetRectMinxin' can't be used as a mixin because it extends a class other than Object.

Health issues and suggestions

Fix lib/binding_helper.dart. (-43.75 points)

Analysis of lib/binding_helper.dart failed with 2 errors:

line 86 col 10: The class 'GetRectMinxin' can't be used as a mixin because it extends a class other than Object.

line 86 col 10: The class 'GetRectMinxin' can't be used as a mixin because it references 'super'.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Error(s) in lib/binding_helper.dart: The class 'GetRectMinxin' can't be used as a mixin because it extends a class other than Object.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.48.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies