intrinsic_grid_view

pub package Likes popularity pub points Platform License

A Custom GridView, IntrinsicGridView provides 2D array of children with Intrinsic width and height.

Having two named Constructors

IntrinsicGridView.vertical scrolls in vertical direction.

IntrinsicGridView.horizontal scrolls in horizontal direction.

GridView vs IntrinsicGridView

Properties GridView IntrinsicGridView
contents overflow Yes No
children width vary with item width No Yes
children height vary with item height No Yes
if any children's height vary,
the adjacent child set new height
No Yes

Usage

  1. Add dependency.

Run this command with Flutter:

$ flutter pub add intrinsic_grid_view

or add following package in your pubspec.yaml file inside the dependencies: section.

dependencies:
  intrinsic_grid_view: ^0.0.2
  1. Importing the library:
import 'package:intrinsic_grid_view/intrinsic_grid_view.dart';
  1. Examples:

IntrinsicGridView.vertical example

code

      IntrinsicGridView.vertical(
          padding: EdgeInsets.only(top: 16, bottom: 12, left: 12, right: 12),
          // columnCount: 3,
          verticalSpace: 10,
          horizontalSpace: 10,
          children: [
            for (var scientist in scientists)
              _buildWidget(scientist),
          ]
      ), // IntrinsicGridView.vertical

IntrinsicGridView.horizontal example

code

      IntrinsicGridView.horizontal(
          padding: EdgeInsets.only(top: 16, bottom: 12, left: 12, right: 12),
          // rowCount: 1,
          verticalSpace: 10,
          horizontalSpace: 10,
          children: [
            for (var scientist in scientists)
              _buildHorizontalWidget(scientist),
          ]
      ), // IntrinsicGridView.horizontal

IntrinsicGridView.vertical + IntrinsicGridView.horizontal example

code

        Column(
          children: [
            Expanded(
              flex: 3,
              child: Row(
                children: [
                  Expanded(
                    child: IntrinsicGridView.vertical(
                        padding: EdgeInsets.only(top: 16, bottom: 12, left: 12, right: 12),
                        columnCount: 1,
                        verticalSpace: 10,
                        horizontalSpace: 10,
                        children: [
                          for (var scientist in scientists)
                            _buildWidget(scientist),
                        ]
                    ), // IntrinsicGridView.vertical
                  ),

                  Expanded(
                    child: IntrinsicGridView.vertical(
                        padding: EdgeInsets.only(top: 16, bottom: 12, left: 12, right: 12),
                        // columnCount: 3,
                        verticalSpace: 10,
                        horizontalSpace: 10,
                        children: [
                          for (var scientist in scientists)
                            _buildWidget(scientist),
                        ]
                    ), // IntrinsicGridView.vertical
                  ),


                ],
              ),
            ),

            Expanded(
              child: IntrinsicGridView.horizontal(
                  padding: EdgeInsets.only(top: 16, bottom: 12, left: 12, right: 12),
                  // rowCount: 1,
                  verticalSpace: 10,
                  horizontalSpace: 10,
                  children: [
                    for (var scientist in scientists)
                      _buildHorizontalWidget(scientist),
                  ]
              ), // IntrinsicGridView.horizontal
            ),
          ],
        ),

Contributing

Suggestions and Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Developer Team:

Amjad Jamali & Kamran Khan

License

Apache 2.0