custom_responsive 1.0.0 copy "custom_responsive: ^1.0.0" to clipboard
custom_responsive: ^1.0.0 copied to clipboard

A lightweight 12-column responsive grid system for Flutter with breakpoints, offsets, nested grids, sliver support, and width-aware builders.

๐Ÿ“ฑ custom_responsive #

A lightweight Bootstrap-style 12-column responsive grid system for Flutter.

custom_responsive helps you build adaptive layouts using responsive column spans, offsets, nested grids, sliver support, and width-aware builders without manually handling screen sizes.


๐Ÿš€ Features #

  • 12-column responsive grid system
  • Breakpoint-based layout control (S, M, XM, L, XL)
  • Column offsets for precise positioning
  • Nested responsive grids
  • Width-aware builders
  • Sliver support
  • Scrollable or shrink-wrapped layouts
  • Custom padding, margin, and color styling
  • Lazy or eager rendering options

๐Ÿ“ฆ Installation #

Add the package to your pubspec.yaml:

dependencies:
  custom_responsive: ^1.0.0

Then run:

flutter pub get

๐Ÿ“ Breakpoints #

Breakpoint Width
S < 600
M 600 - 904
XM 905 - 1239
L 1240 - 1439
XL โ‰ฅ 1440

Values automatically cascade to larger breakpoints when not provided.

Example:

CustomDiv(
  colS: 12,
  colM: 6,
)

is equivalent to:

CustomDiv(
  colS: 12,
  colM: 6,
  colXM: 6,
  colL: 6,
  colXL: 6,
)

๐Ÿงฑ Basic Usage #

import 'package:custom_responsive/custom_responsive.dart';

CustomResponsive(
  children: [
    CustomDiv(
      colS: 12,
      colM: 6,
      colL: 4,
      child: Container(
        height: 100,
        color: Colors.red,
      ),
    ),
    CustomDiv(
      colS: 12,
      colM: 6,
      colL: 8,
      child: Container(
        height: 100,
        color: Colors.blue,
      ),
    ),
  ],
)

โ†”๏ธ Column Offsets #

Offsets allow you to shift items horizontally within the grid.

CustomResponsive(
  children: [
    CustomDiv(
      colS: 6,
      offsetS: 3,
      child: Container(
        height: 100,
        color: Colors.green,
      ),
    ),
  ],
)

๐Ÿช† Nested Grids #

Create responsive layouts inside other responsive layouts.

CustomResponsive(
  children: [
    CustomDiv(
      colS: 12,
      children: [
        CustomDiv(
          colS: 12,
          colM: 6,
          child: Text("Left"),
        ),
        CustomDiv(
          colS: 12,
          colM: 6,
          child: Text("Right"),
        ),
      ],
    ),
  ],
)

๐Ÿ“ Width-Aware Builders #

Use childBuilder when a widget needs to know its allocated width.

CustomDiv(
  colS: 12,
  colM: 6,
  childBuilder: (width) {
    return Text(
      "Available width: ${width.toStringAsFixed(0)}",
    );
  },
)

๐Ÿงช Responsive Spacer #

Create responsive vertical spacing using CustomDiv.space.

CustomResponsive(
  children: [
    CustomDiv(
      colS: 12,
      child: Text("Section A"),
    ),

    CustomDiv.space(24),

    CustomDiv(
      colS: 12,
      child: Text("Section B"),
    ),
  ],
)

You can enable or disable the spacer for specific breakpoints:

CustomDiv.space(
  24,
  s: true,
  m: false,
  l: true,
)

๐Ÿ“œ Scroll Behavior #

Shrink Wrapped (Default) #

Uses a regular Column and sizes itself to its content.

CustomResponsive(
  children: [...],
)

Eager Scrollable #

Uses SingleChildScrollView and builds all rows immediately.

CustomResponsive(
  shrinkWrap: false,
  children: [...],
)

Lazy Scrollable #

Uses ListView.builder and lazily builds rows.

CustomResponsive(
  shrinkWrap: false,
  useBuilder: true,
  children: [...],
)

๐Ÿช Sliver Support #

Use SliverCustomResponsive inside a CustomScrollView.

CustomScrollView(
  slivers: [
    SliverCustomResponsive(
      children: [
        CustomDiv(
          colS: 12,
          colM: 6,
          child: Container(
            height: 100,
            color: Colors.orange,
          ),
        ),
        CustomDiv(
          colS: 12,
          colM: 6,
          child: Container(
            height: 100,
            color: Colors.purple,
          ),
        ),
      ],
    ),
  ],
)

๐Ÿง  Responsive Utilities #

getResponsiveValue #

Returns a value based on the current breakpoint.

final columns = getResponsiveValue<int>(
  context: context,
  valueS: 12,
  valueM: 6,
  valueL: 4,
);

getResponsiveColumnWidth #

Returns the pixel width occupied by a responsive column span.

final width = getResponsiveColumnWidth(
  context: context,
  valueS: 12,
  valueM: 6,
  valueL: 4,
);

๐Ÿ“Œ Notes #

  • The grid uses a 12-column layout system.
  • Column values are automatically clamped to the range 0-12.
  • Offsets are automatically clamped to valid values.
  • Items automatically wrap to a new row when the current row exceeds 12 columns.
  • Nested grids are fully supported.

๐Ÿ“œ License #

MIT License. See the LICENSE file for details.


๐Ÿ’ฌ Feedback & Contributions #

Issues, feature requests, and pull requests are welcome.


Made with โค๏ธ by Amaan

2
likes
0
points
74
downloads

Publisher

verified publisheramaanali.dev

Weekly Downloads

A lightweight 12-column responsive grid system for Flutter with breakpoints, offsets, nested grids, sliver support, and width-aware builders.

Repository (GitHub)
View/report issues

Topics

#responsive #grid #layout #flutter-ui

License

unknown (license)

Dependencies

flutter

More

Packages that depend on custom_responsive