layout_web 1.0.0

layout #

Build layouts with minimal coding.

Purpose and Usage #

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.

Complicated Example #

This would take hundreds of lines to accomplish without the Layout library. #

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.

Pull requests are encouraged. This package was developed to speed up UI design prototyping, and I am not a professional developer with the skills to maintain or tidy up this package. #

Portrait (Tablet) #

alt text

Landscape (Tablet) #

alt text

[1.0.0] - July 28, 2019

  • Patched for web. Uses flutter_for_web package.

##

example/README.md

example #

A new Flutter project.

Getting Started #

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.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  layout_web: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:layout_web/layout_web.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: web

Primary library: package:layout_web/layout_web.dart with components: html, js.

Health suggestions

Fix lib/layout_web.dart. (-0.50 points)

Analysis of lib/layout_web.dart reported 1 hint:

line 9 col 16: Use = to separate a named parameter from its default value.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0-dev.0.1 <3.0.0
flutter_for_web ^1.0.0 1.0.0
flutter_for_web_ui ^1.0.0 1.0.0
Transitive dependencies
collection 1.14.12
intl 0.15.8
meta 1.1.7
path 1.6.4
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^1.4.0
build_web_compilers ^2.0.0