Build layouts with minimal coding.
The library offers a convenient shorthand for laying out complex, responsive layouts in Dart using Google's Flutter framework. Space is divided evenly between elements by default (dynamic flex argument soon to come), and the layout will change automatically depending on screen size (and orientation) with no work required by the code author.
For example, here is a responsive layout that covers the full width of the device screen. It shows two elements, side-by-side, and each taking up 50% of the screen width - the number 1 is displayed in the left box, the number 2 in the right.
new Expanded( child: new Row( children: [ new Expanded(child: Column(children: [ new Text('1') ]), new Expanded(child: new Column(children: [ new Text('2') ]) ] ) )
That's an awful lot of typing. With the layout library, it is as simple as:
new Layout([['1', '2']])
One set of brackets indicates rows. Two sets indicate columns.
This example includes the Cell class - it allows for easy specification of a layout element's padding and color, and also centers its contents by default (you can disable this by passing
center: false). It accepts the same array-style metasyntax as the Layout class.
Also demonstrated are several utilities offered by the library, such as automatic typecasting (numbers and strings are automatically converted to Text widgets), no use of the "child" parameter to save time.
As a bonus, it is possible to code your layout more visually using this array metasyntax - notice how the numbers 1, 2, 3... in the code sample were intentionally arranged in a way that is visually representative of what is displayed in the screenshots.
return Scaffold( appBar: AppBar( title: Text('Test'), ), body: Layout([ // Rows Cell([ // Rows 1, '2' ], color: Colors.blue), Cell([[ // Columns '3', '4', Cell([ // Rows (as a column) '5', '6' ], padding: 32, color: Colors.blue) ]], color: Colors.red, padding: 16) ]));
The included example (located in
/example/) illustrates newly added flex functionality for Cell widgets and building stateful layouts.
A new Flutter project.
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Add this to your package's pubspec.yaml file:
dependencies: layout: ^0.3.0
You can install packages from the command line:
$ flutter packages get
Alternatively, your editor might support
flutter packages get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.3.0||Mar 29, 2019|
|0.2.3||Mar 24, 2019|
|0.2.2||Mar 22, 2019|
|0.2.1||Mar 22, 2019|
|0.2.0||Mar 22, 2019|
|0.1.8||Mar 22, 2019|
|0.1.7||Mar 22, 2019|
|0.1.6||Mar 22, 2019|
|0.1.5||Mar 22, 2019|
|0.1.4||Mar 22, 2019|
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Apr 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.