flutter_bootstrap 1.0.0+2

  • Readme
  • Changelog
  • Example
  • Installing
  • new66

flutter_bootstrap #

A partial implementation of Bootstrap Grid system in Flutter for Responsive Layout.

<br/><br/>


Getting Started #

You should ensure that you add the following dependency in your Flutter project.

dependencies:
 flutter_bootstrap: "^1.0.0+2"

You should then run flutter packages upgrade or update your packages in IntelliJ.

In your Dart code, to use it:

import 'package:flutter_bootstrap/flutter_bootstrap.dart';

Documentation #

This package exposes 4 new Widgets:

  • BootstrapContainer
  • BootstrapRow
  • BootstrapCol
  • BootstrapVisibility

...and a series of helper methods:

  • bootstrapGridParameters
  • bootstrapPrefixBasedOnWidth
  • bootstrapMaxWidthNonFluid
  • bootStrapValueBasedOnSize

It implements the following Bootstrap4 features:

  • .container
  • .container-fluid
  • .row
  • .col-*, .col-sm-*, .col-md-*, .col-lg-*, .col-xl-*
  • .offset-*, .offset-sm-*, .offset-md-*, .offset-lg-*, .offset-xl-*
  • .order-*, .order-sm-*, .order-md-*, .order-lg-*, .order-xl-*
  • conditional visibility based on device width and column definition

Full documentation and examples can be found on my website.


Example #

An example can be found in the example folder. Check it out.

[1.0.0] - Initial stable release #

  • Initial release

[1.0.0+1] #

  • Code formatting

[1.0.0+2] #

  • Warning suppression

example/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_bootstrap/flutter_bootstrap.dart';

void main() => runApp(Application());

class Application extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'flutter_bootstrap Demo',
      home: DemoPage(),
    );
  }
}

class DemoPage extends StatefulWidget {
  @override
  _DemoPageState createState() => _DemoPageState();
}

class _DemoPageState extends State<DemoPage> {
  @override
  void initState() {
    super.initState();
    bootstrapGridParameters(
      gutterSize: 30,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('flutter_bootstap Demo',
            style: TextStyle(color: Colors.black)),
        backgroundColor: Colors.white,
      ),
      body: SingleChildScrollView(
        child: BootstrapContainer(
          fluid: true,
          decoration: BoxDecoration(color: Colors.blue),
          children: [
            BootstrapContainer(
              fluid: false,
              decoration: BoxDecoration(color: Colors.white),
              padding: const EdgeInsets.only(top: 50),
              children: <Widget>[
                BootstrapRow(
                  height: 60,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-6',
                      child: ContentWidget(
                        text: 'col 1 of 2',
                        color: Colors.red,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-6',
                      child: ContentWidget(
                        text: 'col 2 of 2',
                        color: Colors.red,
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 8),
                BootstrapRow(
                  height: 60,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-3',
                      child: ContentWidget(
                        text: 'col 1 of 3',
                        color: Colors.green,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-6',
                      child: ContentWidget(
                        text: 'col 2 of 3 (wider)',
                        color: Colors.red,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-3',
                      child: ContentWidget(
                        text: 'col 3 of 3',
                        color: Colors.green,
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 8),
                Divider(),
                BootstrapRow(
                  height: 120,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-12 col-md-8',
                      child: ContentWidget(
                        text: 'col-12 col-md-8',
                        color: Colors.yellow,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-6 col-md-4',
                      child: ContentWidget(
                        text: 'col-6 col-md-4',
                        color: Colors.green,
                      ),
                    ),
                  ],
                ),
                Divider(),
                BootstrapRow(
                  height: 120,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-9',
                      child: ContentWidget(
                        text: 'col-9',
                        color: Colors.yellow,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-4',
                      child: ContentWidget(
                        text:
                            'col-4\nSince 9+4 = 13 & 13 > 2, this 4-columns gets wrapped onto a new line',
                        color: Colors.green,
                      ),
                    ),
                  ],
                ),
                Divider(),
                BootstrapRow(
                  height: 60,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-md-4',
                      child: ContentWidget(
                        text: 'col-md-8',
                        color: Colors.red,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-md-4',
                      offsets: 'offset-md-4',
                      child: ContentWidget(
                        text: 'col-md-4 offset-md-4',
                        color: Colors.green,
                      ),
                    ),
                  ],
                ),
                BootstrapRow(
                  height: 60,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-md-3',
                      offsets: 'offset-md-3',
                      child: ContentWidget(
                        text: 'col-md-3 offset-md-3',
                        color: Colors.yellow,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-md-3',
                      offsets: 'offset-md-3',
                      child: ContentWidget(
                        text: 'col-md-3 offset-md-3',
                        color: Colors.purple,
                      ),
                    ),
                  ],
                ),
                BootstrapRow(
                  height: 60,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-md-6',
                      offsets: 'offset-md-3',
                      child: ContentWidget(
                        text: 'col-md-6 offset-md-3',
                        color: Colors.yellow,
                      ),
                    ),
                  ],
                ),
                Divider(),
                BootstrapRow(
                  height: 200,
                  children: <BootstrapCol>[
                    BootstrapCol(
                      sizes: 'col-12 col-md-8',
                      orders:
                          'order-2 order-sm-2 order-md-1 order-lg-1 order-xl-1',
                      child: ContentWidget(
                        text: 'col-12 col-md-8 order2(xs,sm)',
                        color: Colors.red,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-12 col-sm-12 col-md-6 col-lg-3 col-xl-3',
                      orders:
                          'order-1 order-sm-1 order-md-2 order-lg-2 order-xl-2',
                      child: ContentWidget(
                        text: 'col 2 order1(xs,sm)',
                        color: Colors.green,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-12 col-sm-12 col-md-6 col-lg-3 col-xl-3',
                      offsets:
                          'offset-0 offset-sm-0 offset-md-2 offset-lg-4 offset-xl-5',
                      orders:
                          'order-3 order-sm-3 order-md-3 order-lg-3 order-xl-3',
                      child: ContentWidget(
                        text: 'col 3',
                        color: Colors.yellow,
                      ),
                    ),
                    BootstrapCol(
                      sizes: 'col-12 col-sm-12 col-md-6 col-lg-3 col-xl-3',
                      orders:
                          'order-4 order-sm-4 order-md-4 order-lg-4 order-xl-4',
                      invisibleForSizes: 'sm xl',
                      child: ContentWidget(
                        text: 'invisible for sm and xl',
                        color: Colors.purple,
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

class ContentWidget extends StatelessWidget {
  const ContentWidget({
    Key key,
    this.text,
    this.color,
  }) : super(key: key);

  final String text;
  final Color color;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 50,
      color: color,
      child: Text(text),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_bootstrap: ^1.0.0+2

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

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

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8