https://github.com/theiskaa/layoutry
A simple layout information builder for your Flutter project
https://github.com/theiskaa/layoutry
flutter flutter-layout flutter-package layout-builder
Last synced: 6 months ago
JSON representation
A simple layout information builder for your Flutter project
- Host: GitHub
- URL: https://github.com/theiskaa/layoutry
- Owner: theiskaa
- License: mit
- Created: 2023-01-10T18:08:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T06:59:46.000Z (over 1 year ago)
- Last Synced: 2025-04-12T22:03:53.445Z (about 1 year ago)
- Topics: flutter, flutter-layout, flutter-package, layout-builder
- Language: Dart
- Homepage: https://pub.dev/packages/layoutry
- Size: 8.79 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Layoutry
## Installing
**See the official installing guidline from [layoutry/install](https://pub.dev/packages/layoutry/install)**
## Usage & Overview

Layoutry is a modified implementation of the **LayoutBuilder**, so that we can use its **LayoutInfo** to easily catch the device's type via its screen size.
Where the **LayoutDevice** is a custom `Platform.operatingSystem` implementation `enum`, which used to mark current device's type by screen size.
Here is the code:
```dart
Layoutry(
builder: (context, info) {
// A manual defined layout-device to color map.
final colors = {
LayoutDevice.mobile: Colors.blue,
LayoutDevice.tablet: Colors.red,
LayoutDevice.web: Colors.green,
};
return AnimatedContainer(
duration: const Duration(milliseconds: 500),
// color will be generated from [colors],
// by listening to device's screen size.
color: colors[info.device],
child: Center(child: Builder(builder: (context) {
// If the device's screen size is like mobile:
// "Hi Mobile" will written in the screen.
if (info.device.isMobile()) {
return const Text(
'Hi Mobile',
style: TextStyle(color: Colors.white, fontSize: 20),
);
}
// If the device's screen size is like web:
// "Hi Web" will written in the screen.
if (info.device.isWeb()) {
return const Text(
'Hi Web',
style: TextStyle(color: Colors.white, fontSize: 20),
);
}
// In other cases: Hi current device's screen size
// appropriate device type will be written in the screen.
return Text(
'Hi ${info.device.toString()}',
style: const TextStyle(color: Colors.white, fontSize: 20),
);
})),
);
},
)
```