fluid_layout 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

Fluid Layout #

pub package

Demo: jamesblasco.github.io/fluid_layout

Fluid gif

Fluid layouts allows you to create responsive layout for mobile, web and desktop from a single codebase.

Let's get started #

Install it #

Follow the installation process here

Understand fluid layout #

Fluid layout aims to help building a responsive experience through all the different screen sizes. Based in the boostrap approach, FluidLayout calculates a padding content (fluid_padding) that changes depending on the parent size. The Fluid widget uses that padding to set its size

The screen sizes are divided in 6 breakpoints: xs, s, m, l, xl, and can be accessed through FluidLayout.of(context).fluidBreakpoint or `context.breakpoint.

You can create values for diferrent screen sizes thanks to the class FluidValue. The easiest way is:

final value = context.fluid(defaultValue, 
  xs: xsValue,  //if null xs would be defaultValue
  s:  sValue,   //if null s would be defaultValue
  m:  mValue,   //if null m would be defaultValue
  l:  lValue,   //if null l would be defaultValue
  xl: xlValue   //if null xl would be defaultValue
 ) 

Examples #

FluidLayout & Fluid #

See web example

class BasicFluidLayout extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[200],
      body: Container(
        child: FluidLayout(
          child: Fluid(
            child: Container(
              color: Colors.blue,
              child: Center(
                child: Text(
                  'Fluid width',
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

There is a fixed horizontalPadding param that can be changed to all the FluidLayout or just for a Fluid container

For CustomScrollView there is a SliverFluid equivalent to Fluid

FluidGridView #

See FluidGridView web example

FluidGridView(
  children: List.filled(
    100,
    FluidCell.withFluidHeight(
      size: context.fluid(3, m: 3, s: 4, xs: 6),
      heightSize: context.fluid(3, m: 3, s: 4, xs: 6),
      child: CustomCard(
        color: Colors.red,
        child: Center(child: Text('Item')),
      )),
    ),
)

Customizable params [double spacing, ScrollPhysics physics, bool shrinkWrap] and bool fluid

FluidCell has three methods to build the cell:

  • FluidCell.fit({size, child})
  • FluidCell.withFluidHeight({size, heightSize, child})
  • FluidCell.withFixedHeight({size, height, child})

For CustomScrollView there is a SliverFluidGrid equivalent to FluidGridView

Conditional Layout #

See Conditional Layout web example

if(FluidLayout.of(context).fluidBreakpoint.isLargerThanM)
   return Container(color: Colors.red)
else
   return Container(color: Colors.red)              

Remember you can use context.breakpoint as FluidLayout.of(context).fluidBreakpoint

Combine full width widgets with fluid layouts #

Fluid layouts can be built everywhere inside the app and they will calculate their constraints based on their parents sizes, also they can combine very easily in cases we need full screen widgets.

  1. Fluid layout with horizontal scroll rows

FluidValue #

TBD

[0.1.0] Released on (2019 December 24) #

example/README.md

example #

A new Flutter application.

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:
  fluid_layout: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:fluid_layout/fluid_layout.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
77
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]
88
Learn more about scoring.

We analyzed this package on Feb 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
flutter_staggered_grid_view ^0.3.0 0.3.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test