Skip to content

kerberjg/auto_layout_frame.dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

auto_layout_frame

Flutter implementation of Figma's Auto Layout frames with support for alignment, padding, gap, resizing, and overflow behavior.

flutter pub add auto_layout_frame

License: MPL-2.0 build example stars
pub package pub score likes

๐Ÿ’™ Use cases

  • ๐ŸŽจ Figma-like layouts: Replicate Figma's Auto Layout behavior in your Flutter apps
  • ๐Ÿ“ฑ Responsive UI: Build flexible, responsive layouts that adapt to different screen sizes
  • ๐Ÿš€ Rapid prototyping: Quickly create complex layouts with an intuitive, declarative syntax

โœจ Features

  • ๐ŸŽฏ Alignment: Control child alignment with alignChildren
  • ๐Ÿ“ Padding & Gap: Set padding around children and gap between them (including auto-spacing with gap: double.infinity)
  • ๐Ÿ“ Resizing: Choose from fixed, hugContents, or fillContainer for horizontal and vertical axes
  • โ†”๏ธ Direction: Layout children horizontally, vertically, or with wrapping
  • ๐Ÿ”„ Overflow handling: Choose from none, clip, visible, or scroll behaviors
  • ๐Ÿช† Proper nesting: Automatically handles nested AutoLayoutFrames with correct constraint handling

Coming soon:

  • ๐Ÿ“š More docs/examples
  • ๐Ÿงฉ More layout options
  • โšก Performance optimizations

๐Ÿ”ฎ Usage Guide

Getting Started

Add auto_layout_frame to your pubspec.yaml:

flutter pub add auto_layout_frame

Then import it in your Dart code:

import 'package:auto_layout_frame/auto_layout_frame.dart';

Basic Example

AutoLayoutFrame(
  direction: AutoLayoutDirection.vertical,
  gap: 16,
  padding: EdgeInsets.all(20),
  alignChildren: Alignment.centerLeft,
  children: [
    Text('Hello'),
    Text('World'),
    Text('Auto Layout!'),
  ],
)

Advanced Example

AutoLayoutFrame(
  direction: AutoLayoutDirection.horizontal,
  gap: double.infinity, // Auto-space children
  padding: EdgeInsets.symmetric(horizontal: 24, vertical: 16),
  alignChildren: Alignment.center,
  horizontalResizing: AutoLayoutResizing.fillContainer,
  verticalResizing: AutoLayoutResizing.hugContents,
  backgroundColor: Colors.blue.shade50,
  overflow: AutoLayoutOverflowBehavior.scroll,
  children: [
    Icon(Icons.star),
    Text('Featured Item'),
    Icon(Icons.arrow_forward),
  ],
)

Resizing

Like Figma, you can control how the frame resizes on both axes:

  • AutoLayoutResizing.fixed: Fixed size (requires explicit width/height)
  • AutoLayoutResizing.hugContents: Shrink-wrap to fit children
  • AutoLayoutResizing.fillContainer: Expand to fill available space

Overflow

New!: Control how overflow is handled when children exceed frame bounds:

  • AutoLayoutOverflowBehavior.none: Allow overflow errors (default)
  • AutoLayoutOverflowBehavior.clip: Clip overflow to frame bounds
  • AutoLayoutOverflowBehavior.visible: Allow overflow to be visible
  • AutoLayoutOverflowBehavior.scroll: Make frame scrollable

๐Ÿ“„ License

This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.

๐Ÿ”ฅ Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. Make sure to read the following guidelines before contributing:

๐Ÿ™ Credits & Acknowledgements

Contributors ๐Ÿง‘โ€๐Ÿ’ป๐Ÿ’™๐Ÿ“

This package is developed/maintained by the following rockstars! Your contributions make a difference! ๐Ÿ’–

contributors badge

Sponsors ๐Ÿซถโœจ๐Ÿฅณ

Kind thanks to all our sponsors! Thank you for supporting the Dart/Flutter community, and keeping open source alive! ๐Ÿ’™

sponsors badge


Based on dart_package_template - a high-quality Dart package template with best practices, CI/CD, and more! ๐Ÿ’™โœจ

About

๐Ÿงฉ๐Ÿฉต Figma's Auto Layout Frame as a Flutter widget

Topics

Resources

License

Code of conduct

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages