GithubHelp home page GithubHelp logo

thealteria / tailor Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 11 KB

Widget that gives you the size of the widget in runtime.

Home Page: https://pub.dev/packages/tailor_flutter

License: MIT License

Dart 100.00%
dart flutter flutter-package package

tailor's Introduction

Tailor

MIT License

Flutter widget that calculates the size of a widget in runtime.

Usage

Just wrap your widget with Tailor and get the size in the builder. The builder will return the size whenever the size of the widget changes.

Tailor(
  builder: (_, size, child) {
    return Container(
      color: Colors.red,
      height: 100,
      width: 100,
      alignment: Alignment.center,
      child: Text(
        "Size: ${size.toString()}",
        textAlign: TextAlign.center,
        style: const TextStyle(color: Colors.white),
      ),
    );
  },
);


We can get the size of any widget using Tailor widget but what if we want to get the size of the AppBar when it's placed in the Scaffold?
Then the Tailor widget will not work and you can't wrap it around the AppBar as it's a normal Widget and AppBar is a PreferredSizeWidget.

class AppBar extends StatefulWidget implements PreferredSizeWidget {


So to tackle this problem we've TailorAppBar. Just wrap the AppBar with TailorAppBar widget when it's placed in the Scaffold and voila! You'll get the size of your AppBar.

Scaffold(
  appBar: TailorAppBar(
    builder: (_, size) {
      return AppBar(
        title: Text('AppBar width: ${size.width} height: ${size.height}'),
      );
    },
  ),
);

tailor's People

Contributors

thealteria avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

shan-shaji

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.