GithubHelp home page GithubHelp logo

flutter-dimens's Introduction

dimens

Android-like dimens generator

Overview

Dimens allows you to manage dimension resources and text styles.

Usage

Add dev dependency to your pubspec.yaml.

dev_dependencies:
  dimens: any

Create sizes.json file under assets/sizes directory in your project.

Here you can declare two objects:

  • textStyles for text styles definitions
  • sizes for dimension definitions
{
  "textStyles": {
    "defaultHeadline": "headline6"
  },
  "sizes": {
    "defaultSpacing": 24.0
  }
}

Then you can define another file for particular screen configuration (only smallest width is supported now), like size-sw320.json. You can override some values here, and these values will be used on devices with smallest width larger or equal 320lp.

{
  "textStyles": {
    "defaultHeadline": "headline5"
  },
  "sizes": {
    "defaultSpacing": 32.0
  }
}

Now run flutter pub run dimens. It will generate dimens.g.dart file containing InheritedWidget called Dimens. Just place this widget at the top of your widget tree. Then you can access appropriate for your screen resource like this:

// ...
Widget build(BuildContext) => Container(
  height: Dimens.of(context).defaultSpacing,
);

Command arguments

Command supports following arguments:

Argument Abbreviation Type Description
--output-dir -o string Directory in which output file will be generated. If not presented file is generated in the root of your project.
--format -f bool Set to true if you want to apply dartfmt to output file. False by default.

flutter-dimens's People

Contributors

defuera avatar ragnor-rs avatar vasyafromrussia avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

severgroup-tt

flutter-dimens's Issues

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.