Code Monkey home page Code Monkey logo

layout's Introduction

Layout

pub package

Following the Material Design Guidelines, Layout encourage consistency across platforms, environments, and screen sizes by using uniform elements and spacing.

Install

Follow the instructions to install it here

Getting started

This package aims to provide the tools to implement a responsive layout in an easy and consistent way.

If you want to learn more in detail about layout in Material Design I recommend you the official website.

Let's get started!

Everything starts with the Layout widget. Usually added at the top of your widget tree, but you can place it wherever you need it. It uses its widget constraints to calculate its breakpoint, columns, gutters, and margins.

  @override
  Widget build(BuildContext context) {
    return Layout(
      child: MaterialApp(
      ....
      ),
    );
  }

Breakpoints

A breakpoint is the range of predetermined screen sizes that have specific layout requirements. At a given breakpoint range, the layout adjusts to suit the screen size and orientation.

Each breakpoint range determines the number of columns, and recommended margins and gutters, for each display size.

By default the breakpoints are defined as:

  • xs: 0 – 599
  • sm: 600 – 1023
  • md: 1024 – 1439
  • lg: 1440 – 1919
  • xl: 1920 +
 @override
 Widget build(BuildContext context) {
   if(context.breakpoint > LayoutBreakpoint.md)
     return TabletView();
   else
     return MobileView();
 }

LayoutValues

A layout value is relative to the width of the screen. This way you can define responsive variable, reuse them and apply them when needed.

final double padding = context.layout.value(xs: 0.0, sm: 12.0, md: 24.0, lg: 32.0, xl: 48.0);

The most important layout values are the ones relative to the breakpoint. These are the most common and useful as you can define a value for different breakpoint sizes. If a breakpoint is not provided, its value will correspond to the first previous/smaller breakpoint.

final double padding = context.layout.value(
     xs: 0.0,  // sm value will be like xs 0.0
     md: 24.0, // lg value will be like md 24.0
     xl: 48.0
);

Layout values can be reused in different parts of the app with even different Layout widgets. For that they need to be created as

final displaySidebar = LayoutValue(xs: false, md: true);

final horizontalMargin = LayoutValue.builder((layout) {
    double margin = layout.width >= 500 ? 24.0 : 16.0;
    margin += 8.0 * layout.visualDensity.horizontal;
    return EdgeInsets.symmetric(horizontal: margin);
});

Then it can be used in any widget that has some Layout up in the tree as:

return Column(
  children: [
    Padding(
      padding: horizontalMargin.resolve(context),
      child:child,
    ),
    if(displaySidebar.resolve(context))
      SideBar(),
    ),
  ],
);

You can also create values relative to the layout width like.

final displaySidebar = LayoutValue.builder((layout) => layout.width > 600);

Margins

Margins are the space between content and the left and right edges of the screen.

  @override
  Widget build(BuildContext context) {
    return Margin(
      child: Text('This text'),
    );
  }

Margin widths are defined as fixed values at each breakpoint range. To better adapt to the screen, the margin width can change at different breakpoints. Wider margins are more appropriate for larger screens, as they create more whitespace around the perimeter of content.

By default the margin values are the ones from the Material Design Guidelines. 16dp for screens with a width less than 720dp and 24 for bigger screens. You can override these values in any moment by providing the margin param.

Fluid Margins

Some times you want to have a fixed width that stays the same across screen sizes.

  @override
  Widget build(BuildContext context) {
    return FluidMargin(
      child: Text('This text'),
    );
  }

Fluid margins are dynamically updated to keep a fixed size of its inner child. These fixed sizes are by default the ones from the Material Design Guidelines but can also easily customizable.

AdaptiveBuilder

A widget that allows easily to build responsive layouts

  @override
  Widget build(BuildContext context) {
    return AdaptiveBuilder(
      xs: (context) => LayoutWithBottomNavigationBar(),
      lg: (context) => LayoutWithTrailingNavigationBar(),
    );
  }

or for more complex cases

  @override
  Widget build(BuildContext context) {
    return  AdaptiveBuilder.builder(
      builder: (context, layout, child) {
        if (layout.breakpoint < LayoutBreakpoint.lg) {
          return LayoutWithBottomNavigationBar(child: child);
        } else {
          return LayoutWithTrailingNavigationBar(child: child);
        }
      },
      child: child,
    );
  }

Contributing

If you want to take the time to make this project better, you can open an new issue, or a pull request.

layout's People

Contributors

andredsnogueira avatar arkangel12 avatar chirag729 avatar deandreamatias avatar ebot64 avatar flakerimi avatar jamesblasco avatar jesusrp98 avatar josh-burton avatar masteradit avatar mono0926 avatar yelwinoo-steve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

layout's Issues

How to have Grid tiles of different length

on version: 0.6.2

I've used the fluid_layout library on a project to build a grid where the tiles had different widths. If there a way to achieve the same thing with the new library? I saw that the fluid_layout was build using StaggeredGridView, tried to used this kind of grid delegate, but some of the children don't appear on the screen when resizing the screen.

Fluid Colums inside Expanded Rows ?

My Question is How can I put responsive Fluid Cells inside SliverToBoxAdapter ?

SliverToBoxAdapter(
                        child: Container(
                          margin: EdgeInsets.symmetric(vertical: 12),
                          padding: EdgeInsets.symmetric(vertical: 12),
                          color: Colors.green,
                          height: 200,
                          child: Center(child: Text('Expanded')),
                        ),
                      ),

I want to put or make content fluid inside expaned. I tried putting Fluid() inside and it works for padding but how can i put fluid cells inside fluid container ? Also all the examples in the lib lacks this example. Where there is expanded fluid widgets there are no fluid cells inside it ? it this because its not doable ?

Logically i tried this but i does not work

SliverToBoxAdapter(
                child: Container(
                  decoration: BoxDecoration(
                    color: Colors.deepPurple,
                  ),
                  child: SliverFluid(
                    sliver: SliverFluidGrid(
                      children: [
                        FluidCell.withFluidHeight(
                          size: context.fluid(2),
                          heightSize: context.fluid(2),
                          child: Container(
                            decoration: BoxDecoration(
                                color: Colors.deepPurple
                            ),
                            child: Image(
                              fit: BoxFit.contain,
                              image: instituteInfo.hasPicture()
                                  ? NetworkImage(instituteInfo.picture.avatar)
                                  : AssetImage(
                                  "assets/imgs/logo-placeholder.png"),
                            ),
                          ),
                        ),
                        FluidCell.withFluidHeight(
                          size: context.fluid(10),
                          heightSize: context.fluid(2),
                          child: Container(
                            decoration: BoxDecoration(
                                color: Colors.deepPurple
                            ),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: <Widget>[
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                ),
              ),

Improve CHANGELOG order

A good practice in changelog, place last version in first place

Expected order:

## [0.5.1] - Add nullable Layout
You can access layout safely with
Layout.maybeOf(context)

## [0.5.0] - First Version

Current order:

## [0.5.0] - First Version

## [0.5.1] - Add nullable Layout
You can access layout safely with
Layout.maybeOf(context)

Publish 1.0.4 to pub.dev

Hello! Can you please publish 1.0.4 (with the gap changes) to pub.dev. Looks like the latest there is 1.0.3, and it is broken on the latest Flutter stable 3.13.1. Thank you!

[Question] How to make the entire FluidLayout scrollable without shrinking its Fluid?

To enable scrolling in any area (Fluid and FluidPadding), a ListView or SingleChildScrollView should be wrapping the entire FluidLayout (please, correct me if I am wrong with this).
Also, to avoid this scroll widget shrinking, it is necessary to wrap it with a Container with its height of double.infinity.
However, the result is a shrunk Fluid.

    Scaffold(
      appBar: AppBar(
        title: Text('Fluid test'),
        centerTitle: true,
      ),
      body: Container(
        height: double.infinity,
        child: SingleChildScrollView(
          physics: AlwaysScrollableScrollPhysics(),
          child: FluidLayout(
            child: Container(
              color: Colors.green,
              child: Fluid(
                child: Container(
                  color: Colors.blue,
                  padding: const EdgeInsets.symmetric(horizontal: 10.0),
                  child: Column(
                    children: [
                      Container(
                        color: Colors.red,
                        height: 50.0,
                        margin: const EdgeInsets.symmetric(vertical: 20.0),
                      ),
                      Container(
                        color: Colors.red,
                        height: 50.0,
                        margin: const EdgeInsets.symmetric(vertical: 20.0),
                      ),
                      Container(
                        color: Colors.red,
                        height: 50.0,
                        margin: const EdgeInsets.symmetric(vertical: 20.0),
                      ),
                      Container(
                        color: Colors.red,
                        height: 50.0,
                        margin: const EdgeInsets.symmetric(vertical: 20.0),
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );

Result:
FluidLayout in green
Fluid in blue
shot

Margin rework

Margin should include the horizontal safe area by default. And an option to remove it.

Layout_proposal

Error: Null safety features are disabled for this library.

Hi,

I'm facing a strange error while trying to run my project with this package. It says that Null safety is disabled for this package.

I've tried to set my SDK version as the as this package but this does not work as well.

layout: ^0.6.0

logs
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:39:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required T xs,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:40:6: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    T? sm,
     ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:41:6: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    T? md,
     ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:42:6: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    T? lg,
     ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:43:6: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    T? xl,
     ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:108:10: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final T? sm;
         ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:109:10: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final T? md;
         ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:110:10: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final T? lg;
         ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:111:10: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final T? xl;
         ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:114:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.xs,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:122:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required T xs,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:123:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required T sm,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:124:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required T md,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:125:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required T lg,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:126:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required T xl,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:133:62: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  BreakpointValue.fromMap(Map<LayoutBreakpoint, T> values, [T? defaultValue])
                                                             ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:8:19: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final EdgeInsets? margin;
                  ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:11:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:12:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.child,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:28:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required LayoutData layout,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:30:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    EdgeInsets? margin,
              ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:31:11: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    double? maxWidth,
          ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:48:19: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final EdgeInsets? margin;
                  ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:51:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:52:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required Widget sliver,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:57:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:58:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required Widget sliver,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:97:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final double? maxWidth;
              ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:98:19: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final EdgeInsets? margin;
                  ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:101:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:102:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.child,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:123:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final double? maxWidth;
              ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:124:19: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final EdgeInsets? margin;
                  ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:128:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/margin.dart:129:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required Widget sliver,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:28:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:29:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.child,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:35:21: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final LayoutFormat? format;
                    ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:41:20: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  static LayoutData? maybeOf(BuildContext context) => context
                   ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:51:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:52:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.size,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:53:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.margin,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:54:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.format,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:55:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.gutter,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:56:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.breakpoint,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:57:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.columns,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:58:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.maxWidth,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:72:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  T value<T>({required T xs, T? sm, T? md, T? lg, T? xl}) {
              ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:72:31: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  T value<T>({required T xs, T? sm, T? md, T? lg, T? xl}) {
                              ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:72:38: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  T value<T>({required T xs, T? sm, T? md, T? lg, T? xl}) {
                                     ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:72:45: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  T value<T>({required T xs, T? sm, T? md, T? lg, T? xl}) {
                                            ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:72:52: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  T value<T>({required T xs, T? sm, T? md, T? lg, T? xl}) {
                                                   ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:110:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:111:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required this.data,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:112:5: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    required Widget child,
    ^^^^^^^^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/breakpoint.dart:10:19: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  LayoutBreakpoint? get smaller {
                  ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/breakpoint.dart:20:19: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  LayoutBreakpoint? get bigger {
                  ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/gutter.dart:6:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final double? extent;
              ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/gutter.dart:9:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/gutter.dart:19:15: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
  final double? extent;
              ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/gutter.dart:22:8: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    Key? key,
       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/fluid_format.dart:10:24: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    LayoutValue<double>? margin,
                       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/material_format.dart:7:24: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    LayoutValue<double>? margin,
                       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/material_format.dart:8:24: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    LayoutValue<double>? gutter,
                       ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/boostrap_format.dart:7:24: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    LayoutValue<double>? margin,
                       ^
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:layout

For solutions, see https://dart.dev/go/unsound-null-safety
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/value.dart:138:62: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
        this.xs = values[LayoutBreakpoint.xs] ?? defaultValue!,
                                                             ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/layout.dart:38:68: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
      .dependOnInheritedWidgetOfExactType<_LayoutInheritedWidget>()!
                                                                   ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/fluid_format.dart:20:65: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
            return min(containerWidth, maxFluidWidth[breakpoint]!);
                                                                ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/fluid_format.dart:26:45: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
            return maxFluidWidth[breakpoint]!;
                                            ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/fluid_format.dart:38:66: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
    final totalDistance = width - breakpoints[breakpoint.smaller]!;
                                                                 ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/fluid_format.dart:41:34: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
        maxFluidWidth[breakpoint]! - maxFluidWidth[breakpoint.smaller]!;
                                 ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/fluid_format.dart:41:71: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
        maxFluidWidth[breakpoint]! - maxFluidWidth[breakpoint.smaller]!;
                                                                      ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/formats/fluid_format.dart:44:41: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
        maxFluidWidth[breakpoint.bigger]! - totalFluidDistance * progress;
                                        ^
../../../Code/flutter_beta/.pub-cache/hosted/pub.dartlang.org/layout-0.6.0/lib/src/format.dart:65:43: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
          width >= breakpoints[breakpoint]!) {
                                          ^
Unhandled exception:
Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.
#0      ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:435:9)
#1      JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:144:33)
#2      FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:632:20)
<asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:545:9)
<asynchronous suspension>
#4      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1105:11)
<asynchronous suspension>
Finished with error: the Dart compiler exited unexpectedly.
Failed to compile application.

[Idea] Separated Row & Column widgets

I'd like to know if it would be interesting to implement the idea of separated Row & Column widgets, using Gutter.
This will allow developers to create Column widgets, where the children are separated according the specific space value.

This is how it wold be used:

 GuttedColumn(
  space: BreakpointValue(xs: 0.0, sm: 10.0).resolve(context),
  children: <Widget>[
    // ...
  ],
),

This is just an idea I had, and I'd like to know if this worth including within this package.

'Gap' version 2.x.x problem for newer version of flutter of dart.

Environment

** Latest Layout Version:**

Description


Apparently, Gap 2.x.x didn't work on newest version of flutter and dart

Steps to reproduce

  1. Change gap version to ^3.0.1, by accepting PR of #28
  2. For those who really need to use this dependencies, you can use this dependencies locally:
  • fork this repo 'layout' to your project
  • change gap version to ^3.0.1 in /pubspec.yaml
  • on your project change layout to a path ;
    layout: path: <layout-directory>/layout #ex: 'lib/package/layout'

Upgrade to Flutter 3.0

I get the following error message since the upgrade to Flutter 3.0.

/opt/homebrew/Caskroom/flutter/2.10.2/flutter/.pub-cache/hosted/pub.dartlang.org/layout-1.0.2/lib/src/layout.dart:134:54: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/opt/homebrew/Caskroom/flutter/2.10.2/flutter/packages/flutter/lib/src/widgets/binding.dart').
package:flutter/…/widgets/binding.dart:1
MediaQueryData.fromWindow(WidgetsBinding.instance!.window,);

Advice on how to have a single row with two boxes that size with the window, one vertical scroll?

Hey there,
I am trying to figure out the best way to go about achieving a single row with two boxes that size with the window, one vertical scrolling?

Here is what I have:

I am wanting them to pretty much be fixed where they are in the image, but if the main windows resizes, I want them to get wider/taller to match the window. (A bit more space between them in the center would be nice, but I can figure that out later).

The biggest issue is with the right side vertical scroll. I am not sure how to add a bit more gap between each one, but even worse, when I currently reize it, it disappears completely as seen here:

https://i.imgur.com/DQzCv7K.mp4

This is my first time using your library, so I tried to Frankenstein it together from bits and pieces of the examples.

If you might be able to offer any assistance, I would greatly appreciate a push in the right direction.
Thanks,
-MH

 return Material(
      type: MaterialType.transparency,
      child: Scaffold(
        body: Container(
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage("assets/images/main1.png"),
              fit: BoxFit.cover,
            ),
          ),
          child:  FluidLayout(
            child: Builder(
              builder: (context) => CustomScrollView(
                slivers: <Widget>[
                  SliverToBoxAdapter(
                      child: SizedBox(
                          height: context.fluid(40, xs: 12, s: 12))),
                  SliverFluidGrid(
                    children: [
                      FluidCell.withFluidHeight(
                          size: context.fluid(6),
                          heightSize: context.fluid(4, m: 4, s: 6, xs: 6),
                          child: CustomCard(
                              child: Container(
                                child: Center(
                                    child: Text(
                                        'Only visible in small screens')),
                              ))),
                      FluidCell.withFluidHeight(
                          size: context.fluid(6),
                          heightSize: context.fluid(4, m: 4, s: 6, xs: 6),
                          child:                    Container(
                            height: 10,
                            child: ListView.separated(
                              itemCount: 10,
                              padding: EdgeInsets.symmetric(
                                  vertical:
                                  FluidLayout.of(context).horizontalPadding +
                                      FluidLayout.of(context).fluidPadding),
                              shrinkWrap: true,
                              scrollDirection: Axis.vertical,
                              itemBuilder: (context, index) => CustomCard(
                                  color: Colors.white70,
                                  child: Container(
                                      height: 100,
                                      width: 100,
                                      child: Center(
                                        child: Text('Item'),
                                      ))),
                              separatorBuilder: (_, __) => SizedBox(
                                  width: FluidLayout.of(context).horizontalPadding),
                            ),
                          ),),
                    ],
                  ),

                ],
              ),
            ),
          ),
        ),
      ),
    );

The following _CastError was thrown building

Environment

ios

Version:
layout: ^1.0.2

Description

I'm having a red error screen when wrapping Layout around MaterialApp and using context.layout.breakpoint

Here is the error :

The following _CastError was thrown building FwpApp(dirty, state: _FwpAppState#4edf4):
Null check operator used on a null value
...
The relevant error-causing widget was:
  FwpApp FwpApp:file:///Users/pierrebresson/Documents/Code/fwp/lib/setup_app.dart:53:22

When the exception was thrown, this was the stack:
#0      Layout.of (package:layout/src/layout.dart:55:68)
#1      LayoutBuildContext.layout (package:layout/src/layout.dart:163:35)
#2      _FwpAppState.build (package:fwp/app.dart:129:18)

Which I believe is caused by the ! operator inside 'src/layout.dart' line 54 :

static LayoutData of(BuildContext context) => context
      .dependOnInheritedWidgetOfExactType<_LayoutInheritedWidget>()!

Steps to reproduce

You can reproduce the issue on this repo. You will get the error if you add Layout and then simply try to use context.layout.breakpoint

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.