AppMasonry class

A true masonry (Pinterest-style) layout that distributes items across columns using a shortest-column greedy algorithm, allowing each child to render at its natural height.

Unlike GridView, no fixed main-axis extent is imposed — items can be as tall or short as they need to be.

Basic usage (list)

AppMasonry(
  columnCount: 2,
  children: cards,
)

Builder usage (lazy)

AppMasonry.builder(
  itemCount: items.length,
  columnCount: 3,
  itemBuilder: (context, index) => ItemTile(items[index]),
)

Adaptive columns (auto-derives column count from width)

AppMasonry(
  maxCrossAxisExtent: 280,
  children: tiles,
)
Inheritance
Available extensions

Constructors

AppMasonry({Key? key, List<Widget>? children, int? itemCount, IndexedWidgetBuilder? itemBuilder, int? columnCount, double maxCrossAxisExtent = 320, double spacing = 12, double runSpacing = 12, EdgeInsetsGeometry padding = EdgeInsets.zero, ScrollPhysics? physics, bool shrinkWrap = false, bool reverse = false, bool? primary, ScrollController? controller})
Creates a masonry layout.
const
AppMasonry.builder({Key? key, required int itemCount, required IndexedWidgetBuilder itemBuilder, int? columnCount, double maxCrossAxisExtent = 320, double spacing = 12, double runSpacing = 12, EdgeInsetsGeometry padding = EdgeInsets.zero, ScrollPhysics? physics, bool shrinkWrap = false, bool reverse = false, bool? primary, ScrollController? controller})
Creates a masonry layout using a builder function.
const

Properties

centered → Widget

Available on Widget, provided by the WidgetX extension

Wraps the widget in a Center.
no setter
children → List<Widget>?
Explicit list of children (default constructor).
final
columnCount → int?
Fixed column count. When null, derived from maxCrossAxisExtent.
final
controller → ScrollController?
External scroll controller.
final
hashCode → int
The hash code for this object.
no setterinherited
itemBuilder → IndexedWidgetBuilder?
Lazy builder (AppMasonry.builder).
final
itemCount → int?
Total item count (AppMasonry.builder).
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxCrossAxisExtent → double
Maximum column width used when columnCount is null.
final
padding → EdgeInsetsGeometry
Padding around the scroll content.
final
physics → ScrollPhysics?
Scroll physics.
final
primary → bool?
Whether this is the primary scroll view.
final
repaint → Widget

Available on Widget, provided by the WidgetX extension

Wraps in RepaintBoundary to isolate repaints.
no setter
reverse → bool
Reverses scroll direction.
final
runSpacing → double
Vertical gap between items in the same column.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shrinkWrap → bool
Sizes the scroll view to its content.
final
spacing → double
Horizontal gap between columns.
final

Methods

animatedSwitcher({Duration duration = const Duration(milliseconds: 300), AnimatedSwitcherTransitionBuilder transitionBuilder = _defaultAnimatedSwitcherTransition, AnimatedSwitcherLayoutBuilder layoutBuilder = AnimatedSwitcher.defaultLayoutBuilder}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps in an AnimatedSwitcher with duration and default fade.
build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
expanded({int flex = 1}) → Widget

Available on Widget, provided by the WidgetX extension

Expands the widget inside a Flex parent.
fadeIn({double opacity = 1, Duration duration = const Duration(milliseconds: 300), Curve curve = Curves.easeIn}) → Widget

Available on Widget, provided by the WidgetAnimateX extension

Wraps in an AnimatedOpacity.
flexible({int flex = 1, FlexFit fit = FlexFit.loose}) → Widget

Available on Widget, provided by the WidgetX extension

Applies flexible sizing.
keyed(Object key) → Widget

Available on Widget, provided by the WidgetX extension

Wraps the widget in a KeyedSubtree with key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onTap(VoidCallback onTap, {HitTestBehavior behavior = HitTestBehavior.opaque}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps the widget in GestureDetector with onTap.
pad({double horizontal = 0, double vertical = 0}) → Widget

Available on Widget, provided by the WidgetX extension

Applies symmetric padding.
padded([double padding = AppSpacing.lg]) → Widget

Available on Widget, provided by the WidgetX extension

Applies uniform padding.
scaleOnTap({double scale = 0.95, required VoidCallback onTap, Duration duration = const Duration(milliseconds: 150)}) → Widget

Available on Widget, provided by the WidgetAnimateX extension

Wraps in an AnimatedScale.
semantics({required String label, bool button = false}) → Widget

Available on Widget, provided by the WidgetX extension

Wraps in a Semantics node with label.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited
visible({bool condition = true}) → Widget

Available on Widget, provided by the WidgetX extension

Hides the widget entirely when condition is false.
withPadding(EdgeInsetsGeometry padding) → Widget

Available on Widget, provided by the WidgetX extension

Applies padding only.

Operators

operator ==(Object other) → bool
The equality operator.
inherited