dimension
0.2.1, released 5 weeks ago by wenkaifan.com
Mimics CSS length units (px, percentage, vw, vh, vmin, vmax) for responsive Flutter layouts.
What it does
Introduces a Dimension class that mimics CSS length units, allowing developers to calculate sizes based on parent constraints and screen dimensions. It includes DimensionSizedBox and AnimatedDimensionSizedBox widgets to simplify responsive design and animations.
AI-written summary of version 0.2.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to use CSS-like length units such as vw, vh, percentage, or vmin/vmax in Flutter.
- You need to easily tween or animate sizes across different units.
- You want a SizedBox alternative that reacts to screen size and parent constraints using Dimension values.
Skip it when
- You are already using a comprehensive responsive layout framework that provides its own scaling mechanism.
- You do not need CSS-style units and standard Flutter constraints are sufficient.
Strengths
- Supports multiple CSS-like units including px, percentage, vw, vh, vmin, and vmax.
- Supports serialization and deserialization of dimensions.
- Provides built-in widgets like DimensionSizedBox and AnimatedDimensionSizedBox.
Weaknesses
- Requires explicitly passing screen sizes or using its specific wrapper widgets.
- Relies on manual context/constraint handling outside of the provided widgets.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
var length = 10.toPXLength;
double px = length.toPX(constraint: 100, screenSize: MediaQuery.sizeOf(context));Alternatives
Packages that do the same job and could replace dimension.
- responsive_framework
If you need full-scale adaptive and responsive scaling across different screen sizes automatically.
50Compare - sizer
If you prefer calculating sizes based on device screen width and height percentages via simple extensions.
63Compare
Works with
Packages commonly used together with dimension: ones it builds on, ones built on it, and its own family.
- flutter_class_parserdimension depends on itSerialize and deserialize common Flutter UI data classes and widgets.
- responsive_propertySame familyResponsive values and widgets based on screen size using ScreenScope and Responsive classes
- morphable_shapeBuilt on dimensionCreate responsive shapes and morph between them in Flutter.
- animated_styled_widgetBuilt on dimensionSerializable CSS-inspired styles with implicit and explicit animations for custom widgets.