简体   繁体   中英

How to use Dimens in Flutter?

I want to use something similar to androids dimens.xml to enforce consistency through out my app.

I was sure Material Design would have some predefined values to use, considering how heavily integrated it is in Flutter, but I cant find anything like it.

Have I just missed it? If not, whats the best approach of implementing it? Just a class holding static variables?

Not sure whether this fully answers your question. But there is a new pub package for Android like dimens.xml file. This package is released in Aug 2020.

https://pub.dev/packages/dimens

At the time of writing this, this package only supports Smallest width based (like sw320) categorization of devices. Hope they expand the library to include dencity based categorization as well.

The only other option I can think of right now is to use a static class with constant values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM