tailwindcss_build 0.4.6
tailwindcss_build: ^0.4.6 copied to clipboard
A comprehensive Flutter package that brings the power and convenience of Tailwind CSS utility classes to Flutter development.
TailwindCSS Build for Flutter #
Transform your Flutter development with the power and elegance of Tailwind CSS utility classes through our revolutionary Builder Pattern architecture.
🚨 Pre-1.0.0 Notice #
Important: This package is in active development toward version 1.0.0. We may introduce breaking changes, deprecate APIs, or make architectural improvements to provide the best possible solution.
Current Status: The builder pattern implementations (ContainerBuilder, TextBuilder, FlexBuilder) in v0.4.0 are production-ready and represent the future direction of this library.
✨ Why TailwindCSS Build? #
🎯 Before vs After Comparison #
🔥 Simple Button Example
Traditional Flutter Way (Verbose):
GestureDetector(
onTap: () => print('Button clicked!'),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
decoration: BoxDecoration(
color: Color(0xFF2563EB), // blue-600
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: Offset(0, 2),
),
],
),
child: Text(
'Click Me',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
)
TailwindCSS Build Way (Elegant):
Text('Click Me')
.asText()
.textWhite()
.fontMedium()
.asContainer()
.px6()
.py3()
.bgBlue600()
.r8()
.shadow()
.onTap(() => print('Button clicked!'))
Result: ✨ 70% less code, 100% more readable!
🎨 Card Layout Example
Traditional Flutter Way:
Container(
padding: EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 10,
offset: Offset(0, 4),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Card Title',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color(0xFF111827), // gray-900
),
),
SizedBox(height: 8),
Text(
'Card content goes here...',
style: TextStyle(
fontSize: 16,
color: Color(0xFF4B5563), // gray-600
),
),
],
),
)
TailwindCSS Build Way:
[
Text('Card Title')
.asText()
.textXl()
.fontBold()
.textGray900()
.build(),
SizedBox(height: 8),
Text('Card content goes here...')
.asText()
.textBase()
.textGray600()
.build(),
].asFlex()
.flexCol()
.itemsStart()
.asContainer()
.bgWhite()
.p6()
.r12()
.shadowMd()
.build()
Result: ✨ Self-documenting code with visual clarity!
🔄 Complex Responsive Layout Example
Traditional Flutter Way:
Container(
padding: EdgeInsets.all(16),
color: Color(0xFFF3F4F6), // gray-100
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Color(0xFFEFF6FF), // blue-50
borderRadius: BorderRadius.circular(8),
),
child: Text(
'Left Panel',
style: TextStyle(
color: Color(0xFF1E40AF), // blue-700
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(width: 16),
Expanded(
child: Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Color(0xFFF0FDF4), // green-50
borderRadius: BorderRadius.circular(8),
),
child: Text(
'Right Panel',
style: TextStyle(
color: Color(0xFF15803D), // green-700
fontWeight: FontWeight.w500,
),
),
),
),
],
),
)
TailwindCSS Build Way:
[
Text('Left Panel')
.asText()
.textBlue700()
.fontMedium()
.asContainer()
.bgBlue50()
.p4()
.r8()
.wFull()
.build(),
Text('Right Panel')
.asText()
.textGreen700()
.fontMedium()
.asContainer()
.bgGreen50()
.p4()
.r8()
.wFull()
.build(),
].asFlex()
.flexRow()
.justifyBetween()
.itemsStretch()
.asContainer()
.bgGray100()
.p4()
.build()
Result: ✨ Visual code structure matches UI layout!
🏗️ Revolutionary Architecture #
🎯 Builder Pattern Benefits #
- 🚀 Performance: Single widget creation instead of nested containers
- 🔗 Chainable: Intuitive method chaining for complex styling
- 🛡️ Type Safe: Full compile-time checking with Flutter's type system
- 💾 Memory Efficient: Reduced widget tree depth and improved rendering
🧩 Three Core Builders #
Builder | Purpose | Features | Usage |
---|---|---|---|
TextBuilder | Text styling & typography | Decoration, Transform, Overflow control | Text('Hello').asText().textBlue600().underline().decorationRed500().build() |
ContainerBuilder | Layout, spacing & visual effects | Complete Position system | .asContainer().px6().py3().bgWhite().positionAbsolute(top: 10, left: 20).build() |
FlexBuilder | Layout management (Row/Column) | Flex properties and gap control | [widgets].asFlex().flexRow().justifyCenter().gap4().asContainer().build() |
🚀 Quick Start #
Installation #
dependencies:
tailwindcss_build: ^0.4.4
Import #
import 'package:tailwindcss_build/tailwindcss_build.dart';
Basic Usage Patterns #
📝 Advanced Text Styling
// Basic text styling
Text('Hello World')
.asText()
.textBlue600() // Color
.textXl() // Size
.fontBold() // Weight
.build()
// Advanced text decorations
Text('Styled Text')
.asText()
.textRed600()
.underline() // Underline decoration
.decorationBlue500() // Decoration color
.decorationDotted() // Decoration style
.decoration2() // Decoration thickness
.build()
// Text transformations
Text('transform me')
.asText()
.uppercase() // TEXT TRANSFORM
.trackingWide() // Letter spacing
.leadingLoose() // Line height
.build()
// Text overflow control
Text('Very long text that might overflow...')
.asText()
.truncate() // Ellipsis overflow
.maxLines(2) // Max lines
.build()
🎯 Advanced Container Styling
// Basic container
Text('Content')
.build()
.asContainer()
.px6() // Horizontal padding
.py3() // Vertical padding
.bgBlue600() // Background color
.r8() // Border radius
.shadow() // Drop shadow
.build()
// Position layouts
Text('Positioned Element')
.asText()
.textWhite()
.fontMedium()
.asContainer()
.px4()
.py2()
.bgRed500()
.r6()
.positionAbsolute( // Absolute positioning
top: 20,
right: 10,
width: 200,
)
// Tailwind-style positioning
Text('Fixed Element')
.asContainer()
.px6()
.py3()
.bgBlue600()
.top0() // top: 0
.right4() // right: 16px
.insetX2() // left: 8px, right: 8px
.positionFixed()
// Combined positioning
Widget()
.asContainer()
.position() // Enable positioning
.top(50) // Custom top value
.left0() // Left edge
.w64() // Width control
.h32() // Height control
.bgGreen500()
.build()
🔄 Flex Layouts
// Row layout
[
Text('Item 1').build(),
Text('Item 2').build(),
Text('Item 3').build(),
].asFlex()
.flexRow() // Direction
.justifyCenter() // Main axis alignment
.itemsCenter() // Cross axis alignment
.asContainer() // Convert to container for styling
.bgGray100()
.p4()
.r8()
.build()
// Column layout
[
Text('Title').build(),
Text('Subtitle').build(),
].asFlex()
.flexCol()
.itemsStart()
.asContainer()
.bgWhite()
.p6()
.shadowMd()
.build()
🎮 Interactive Elements
// Clickable button
Text('Click Me')
.asText()
.textWhite()
.fontMedium()
.asContainer()
.px6()
.py3()
.bgBlue600()
.r8()
.shadow()
.onTap(() {
print('Button clicked!');
})
// No manual GestureDetector needed!
🌐 Platform Support #
✅ Fully Supported Platforms #
This package supports all Flutter platforms:
- 📱 Android - Full support for mobile apps
- 🍎 iOS - Complete iOS compatibility
- 🌐 Web - Web application support
- 🖥️ Windows - Desktop Windows apps
- 🍎 macOS - Desktop macOS apps
- 🐧 Linux - Desktop Linux apps
🎯 Zero Configuration Required #
Works out of the box on all platforms with no additional setup needed.
🎨 Complete Color System #
🌈 All TailwindCSS Colors Available #
Background Colors (21 color families)
// Basic colors
.bgWhite() .bgBlack() .bgTransparent()
// Gray family (50-950)
.bgGray50() .bgGray100() .bgGray200() ... .bgGray950()
// All color families with full ranges:
.bgSlate50() → .bgSlate950() // Slate
.bgZinc50() → .bgZinc950() // Zinc
.bgNeutral50() → .bgNeutral950() // Neutral
.bgStone50() → .bgStone950() // Stone
.bgRed50() → .bgRed950() // Red
.bgOrange50() → .bgOrange950() // Orange
.bgAmber50() → .bgAmber950() // Amber
.bgYellow50() → .bgYellow950() // Yellow
.bgLime50() → .bgLime950() // Lime
.bgGreen50() → .bgGreen950() // Green
.bgEmerald50() → .bgEmerald950() // Emerald
.bgTeal50() → .bgTeal950() // Teal
.bgCyan50() → .bgCyan950() // Cyan
.bgSky50() → .bgSky950() // Sky
.bgBlue50() → .bgBlue950() // Blue
.bgIndigo50() → .bgIndigo950() // Indigo
.bgViolet50() → .bgViolet950() // Violet
.bgPurple50() → .bgPurple950() // Purple
.bgFuchsia50() → .bgFuchsia950() // Fuchsia
.bgPink50() → .bgPink950() // Pink
.bgRose50() → .bgRose950() // Rose
Border Colors (All families)
// Default border (gray-200)
.border()
// Colored borders
.border().borderBlue500()
.border().borderRed300()
.border().borderGreen600()
// Custom border color
.border(color: Colors.purple)
// All border color families available:
.borderGray50() → .borderGray950()
.borderBlue50() → .borderBlue950()
.borderRed50() → .borderRed950()
// ... all 21 color families
📐 Size Constraints System (NEW in v0.4.4) #
🎯 Complete Size Control #
TailwindCSS Build now includes comprehensive size constraints support, giving you precise control over element dimensions:
📏 Min/Max Width Examples
// Min-Width Examples
Text('Content')
.asContainer()
.minW32() // min-width: 128px
.minW48() // min-width: 192px
.minWFull() // min-width: 100%
.minWScreen() // min-width: 100vw
.build()
// Max-Width Examples
Text('Content')
.asContainer()
.maxWsm() // max-width: 384px
.maxWmd() // max-width: 448px
.maxWlg() // max-width: 512px
.maxWFull() // max-width: 100%
.build()
// Container Scale Sizes
Text('Responsive Content')
.asContainer()
.minWsm() // min-width: 24rem (384px)
.maxWlg() // max-width: 32rem (512px)
.build()
📐 Min/Max Height Examples
// Min-Height Examples
Text('Content')
.asContainer()
.minH16() // min-height: 64px
.minH24() // min-height: 96px
.minHFull() // min-height: 100%
.minHScreen() // min-height: 100vh
.build()
// Max-Height Examples
Text('Scrollable Content')
.asContainer()
.maxH32() // max-height: 128px
.maxH48() // max-height: 192px
.maxHFull() // max-height: 100%
.maxHScreen() // max-height: 100vh
.build()
// Container Scale Heights
Text('Responsive Height')
.asContainer()
.minHmd() // min-height: 28rem (448px)
.maxHxl() // max-height: 36rem (576px)
.build()
🎨 Advanced Constraint Combinations
// Complex Size Constraints
Text('Flexible Content')
.asContainer()
.minW(200) // min-width: 200px
.maxW(600) // max-width: 600px
.minH(100) // min-height: 100px
.maxH(400) // max-height: 400px
.bgBlue50()
.p4()
.r8()
.build()
// Responsive Card with Constraints
Text('Card Content')
.asContainer()
.minWsm() // min-width: 24rem
.maxW2xl() // max-width: 42rem
.minH32() // min-height: 128px
.maxH96() // max-height: 384px
.bgWhite()
.p6()
.r12()
.shadowLg()
.build()
// Content-based Sizing
Text('Auto-sizing Content')
.asContainer()
.minWMin() // min-width: min-content
.maxWMax() // max-width: max-content
.minHFit() // min-height: fit-content
.maxHFit() // max-height: fit-content
.bgGreen50()
.p4()
.r6()
.build()
🏗️ Technical Implementation #
- BoxConstraints Integration: All constraints use Flutter's native BoxConstraints system
- Performance Optimized: Single Container with merged constraints
- Cross-Platform: Works on all Flutter platforms (Android, iOS, Web, Windows, macOS, Linux)
- Type Safe: Full compile-time checking and IntelliSense support
🎯 Position Layout System #
📐 Complete Positioning Control #
TailwindCSS Build includes a comprehensive positioning system that mirrors TailwindCSS positioning utilities:
🎯 Position Types
// Static Positioning (Default)
Text('Static Element')
.asContainer()
.positionStatic()
.bgBlue500()
.p4()
.build()
// Relative Positioning
Text('Relative Element')
.asContainer()
.positionRelative()
.bgGreen500()
.p4()
.build()
// Absolute Positioning
Text('Absolute Element')
.asContainer()
.positionAbsolute(
top: 20,
left: 10,
width: 200,
height: 100,
)
.bgRed500()
.p4()
.build()
// Fixed Positioning
Text('Fixed Element')
.asContainer()
.positionFixed(
top: 0,
right: 0,
width: 100,
height: 50,
)
.bgPurple500()
.p4()
.build()
// Sticky Positioning
Text('Sticky Element')
.asContainer()
.positionSticky()
.bgYellow500()
.p4()
.build()
📏 Tailwind-style Position Values
// Top Positioning
Text('Top Positioned')
.asContainer()
.top0() // top: 0
.top1() // top: 4px
.top2() // top: 8px
.top4() // top: 16px
.top(50) // top: 50px (custom value)
.positionAbsolute()
.bgBlue500()
.build()
// Right Positioning
Text('Right Positioned')
.asContainer()
.right0() // right: 0
.right1() // right: 4px
.right2() // right: 8px
.right4() // right: 16px
.right(30) // right: 30px (custom value)
.positionAbsolute()
.bgGreen500()
.build()
// Bottom Positioning
Text('Bottom Positioned')
.asContainer()
.bottom0() // bottom: 0
.bottom1() // bottom: 4px
.bottom2() // bottom: 8px
.bottom4() // bottom: 16px
.bottom(20) // bottom: 20px (custom value)
.positionAbsolute()
.bgRed500()
.build()
// Left Positioning
Text('Left Positioned')
.asContainer()
.left0() // left: 0
.left1() // left: 4px
.left2() // left: 8px
.left4() // left: 16px
.left(10) // left: 10px (custom value)
.positionAbsolute()
.bgPurple500()
.build()
⚡ Inset Shortcuts
// All Directions
Text('Inset All')
.asContainer()
.inset0() // top: 0, right: 0, bottom: 0, left: 0
.inset1() // top: 4px, right: 4px, bottom: 4px, left: 4px
.inset2() // top: 8px, right: 8px, bottom: 8px, left: 8px
.inset4() // top: 16px, right: 16px, bottom: 16px, left: 16px
.positionAbsolute()
.bgBlue500()
.build()
// Horizontal (X-axis)
Text('Inset X')
.asContainer()
.insetX0() // left: 0, right: 0
.insetX1() // left: 4px, right: 4px
.insetX2() // left: 8px, right: 8px
.positionAbsolute()
.bgGreen500()
.build()
// Vertical (Y-axis)
Text('Inset Y')
.asContainer()
.insetY0() // top: 0, bottom: 0
.insetY1() // top: 4px, bottom: 4px
.insetY2() // top: 8px, bottom: 8px
.positionAbsolute()
.bgRed500()
.build()
🎨 Advanced Position Combinations
// Complex Positioning
Text('Complex Positioned')
.asContainer()
.position() // Enable positioning
.top(50) // Custom top value
.left0() // Left edge
.w64() // Width control
.h32() // Height control
.bgOrange500()
.p4()
.r8()
.build()
// Responsive Positioning
Text('Responsive Positioned')
.asContainer()
.positionAbsolute(
top: 20,
right: 10,
width: 200,
height: 100,
)
.bgIndigo500()
.p4()
.r8()
.shadowLg()
.build()
// Custom Positioned Helper
Text('Custom Positioned')
.asContainer()
.positioned(
top: 30,
right: 20,
bottom: 10,
left: 15,
width: 300,
height: 150,
)
.bgPink500()
.p6()
.r12()
.build()
🏗️ Position System Features #
- TailwindCSS Compatible: Matches official TailwindCSS positioning syntax
- Flutter Optimized: Uses native Positioned widget for absolute/fixed positioning
- Type Safe: Full compile-time checking for position values
- Flexible: Supports both preset values and custom positioning
- Performance: Efficient widget tree with minimal nesting
📚 Advanced Examples #
🏢 Dashboard Layout
[
// Header
Text('Dashboard')
.asText()
.text2xl()
.fontBold()
.textGray900()
.asContainer()
.px6()
.py4()
.bgWhite()
.borderB()
.borderGray200()
.build(),
// Content area
[
// Sidebar
[
Text('Navigation').build(),
Text('Menu Item 1').build(),
Text('Menu Item 2').build(),
].asFlex()
.flexCol()
.itemsStart()
.asContainer()
.bgGray50()
.p4()
.w64()
.build(),
// Main content
Text('Main Content Area')
.asContainer()
.bgWhite()
.p6()
.wFull()
.build(),
].asFlex()
.flexRow()
.itemsStretch()
.asContainer()
.hFull()
.build(),
].asFlex()
.flexCol()
.asContainer()
.hFull()
.bgGray100()
.build()
💳 Product Card
[
// Product image placeholder
Container(height: 200, color: Colors.grey[300]),
// Product info
[
Text('Product Name')
.asText()
.textLg()
.fontSemibold()
.textGray900()
.build(),
Text('\$29.99')
.asText()
.textXl()
.fontBold()
.textGreen600()
.build(),
Text('Product description goes here...')
.asText()
.textSm()
.textGray600()
.build(),
// Action buttons
[
Text('Add to Cart')
.asText()
.textWhite()
.fontMedium()
.asContainer()
.px4()
.py2()
.bgBlue600()
.r6()
.onTap(() {}),
Text('♡')
.asText()
.textGray400()
.asContainer()
.px3()
.py2()
.border()
.borderGray300()
.r6()
.onTap(() {}),
].asFlex()
.flexRow()
.justifyBetween()
.itemsCenter()
.build(),
].asFlex()
.flexCol()
.itemsStart()
.asContainer()
.p4()
.build(),
].asFlex()
.flexCol()
.asContainer()
.bgWhite()
.r12()
.shadowLg()
.build()
📱 Mobile-First Form
[
Text('Sign Up')
.asText()
.text2xl()
.fontBold()
.textCenter()
.textGray900()
.build(),
SizedBox(height: 24),
// Email input
TextFormField(
decoration: InputDecoration(
hintText: 'Enter your email',
border: OutlineInputBorder(),
),
).asContainer()
.px4()
.py2()
.bgWhite()
.border()
.borderGray300()
.r8()
.build(),
SizedBox(height: 16),
// Password input
TextFormField(
obscureText: true,
decoration: InputDecoration(
hintText: 'Enter your password',
border: OutlineInputBorder(),
),
).asContainer()
.px4()
.py2()
.bgWhite()
.border()
.borderGray300()
.r8()
.build(),
SizedBox(height: 24),
// Submit button
Text('Create Account')
.asText()
.textWhite()
.fontMedium()
.textCenter()
.asContainer()
.px6()
.py3()
.bgBlue600()
.r8()
.shadow()
.wFull()
.onTap(() {}),
].asFlex()
.flexCol()
.asContainer()
.bgGray50()
.p6()
.wFull()
.build()
🎯 Performance & Best Practices #
⚡ Performance Benefits #
Widget Tree Optimization
Before (Multiple nested containers):
Container
└── Container (padding)
└── Container (background)
└── Container (border)
└── Container (shadow)
└── Text
After (Single optimized container):
Container (all properties merged)
└── Text
Result: 🚀 5x fewer widgets, 3x faster rendering
🛡️ Type Safety & IntelliSense #
// Full autocompletion support
Text('Hello')
.asText()
.text // ← Shows: textXs, textSm, textBase, textLg...
.font // ← Shows: fontThin, fontLight, fontNormal...
.asContainer()
.bg // ← Shows: bgWhite, bgBlack, bgGray50...
.p // ← Shows: p1, p2, p3, px2, py4...
📋 Recommended Chain Order #
// Optimal chaining pattern
Text('Text')
.asText() // 1. Convert to text builder
.textXl() // 2. Text-specific styles
.fontBold() //
.textBlue600() //
.asContainer() // 3. Convert to container builder
.px6() // 4. Spacing
.py3() //
.bgWhite() // 5. Background
.border() // 6. Border
.borderGray300() //
.r8() // 7. Border radius
.shadow() // 8. Effects
.build() // 9. Final build
📖 API Reference #
🏗️ Core Builders #
TextBuilder Methods
// Text Sizes
.textXs() .textSm() .textBase() .textLg()
.textXl() .text2xl() .text3xl() .text4xl()
// Font Weights
.fontThin() .fontLight() .fontNormal() .fontMedium()
.fontSemibold() .fontBold() .fontExtrabold() .fontBlack()
// Text Colors (all TailwindCSS colors)
.textWhite() .textBlack() .textGray50() ... .textGray950()
.textRed50() ... .textRed950() // All color families
// Text Alignment
.textLeft() .textCenter() .textRight() .textJustify()
// Text Decoration Line
.underline() .overline() .lineThrough() .noUnderline()
.underlineLineThrough() .underlineOverline() .allDecorations()
// Text Decoration Style
.decorationSolid() .decorationDouble() .decorationDotted()
.decorationDashed() .decorationWavy()
// Text Decoration Thickness
.decoration0() .decoration1() .decoration2() .decoration4() .decoration8()
.decorationAuto() .decorationFromFont() .decorationCustom(3.5)
// Text Decoration Colors (Full TailwindCSS palette)
.decorationRed500() .decorationBlue600() .decorationGreen700()
.decorationPurple500() .decorationYellow400() // All color families
// Text Transform
.uppercase() .lowercase() .capitalize() .normalCase()
// Text Overflow & Wrap
.truncate() .textEllipsis() .textClip()
.textWrap() .textNowrap() .textBalance() .textPretty()
// Line Height & Letter Spacing
.leadingNone() .leadingTight() .leadingSnug() .leadingNormal()
.leadingRelaxed() .leadingLoose()
.trackingTighter() .trackingTight() .trackingNormal() .trackingWide()
.trackingWider() .trackingWidest()
ContainerBuilder Methods
// Padding & Margin
.p0() .p1() .p2() .p3() .p4() ... .p96()
.px0() .py0() .pl0() .pr0() .pt0() .pb0() // Directional
.m0() .m1() .m2() ... .m96() // Margin variants
// Background Colors (all TailwindCSS colors)
.bgWhite() .bgBlack() .bgTransparent()
.bgGray50() ... .bgGray950() // All color families
// Border
.border() .borderT() .borderR() .borderB() .borderL()
.border0() .border2() .border4() .border8() // Widths
.borderSolid() .borderDashed() .borderDotted()
// Border Colors
.borderGray50() ... .borderGray950() // All color families
// Border Radius
.r0() .r1() .r2() .r3() .r4() .r6() .r8() .r12() .r16() .r20() .r24()
.rFull() .rNone()
// Shadows
.shadow() .shadowSm() .shadowMd() .shadowLg() .shadowXl() .shadow2xl()
.shadowInner() .shadowNone()
// Size
.w0() .w1() ... .w96() .wAuto() .wFull() .wScreen()
.h0() .h1() ... .h96() .hAuto() .hFull() .hScreen()
// Size Constraints (NEW in v0.4.4)
// Min-Width
.minW0() .minW1() ... .minW96() .minWAuto() .minWFull() .minWScreen()
.minWMin() .minWMax() .minWFit() .minW(double) .minWCustom(double)
// Max-Width
.maxW0() .maxW1() ... .maxW96() .maxWAuto() .maxWFull() .maxWScreen()
.maxWMin() .maxWMax() .maxWFit() .maxW(double) .maxWCustom(double)
// Min-Height
.minH0() .minH1() ... .minH96() .minHAuto() .minHFull() .minHScreen()
.minHMin() .minHMax() .minHFit() .minH(double) .minHCustom(double)
// Max-Height
.maxH0() .maxH1() ... .maxH96() .maxHAuto() .maxHFull() .maxHScreen()
.maxHMin() .maxHMax() .maxHFit() .maxH(double) .maxHCustom(double)
// Container Scale Sizes
.minW3xs() .minW2xs() .minWxs() .minWsm() .minWmd() .minWlg() .minWxl()
.minW2xl() .minW3xl() .minW4xl() .minW5xl() .minW6xl() .minW7xl()
.maxW3xs() .maxW2xs() .maxWxs() .maxWsm() .maxWmd() .maxWlg() .maxWxl()
.maxW2xl() .maxW3xl() .maxW4xl() .maxW5xl() .maxW6xl() .maxW7xl()
.minH3xs() .minH2xs() .minHxs() .minHsm() .minHmd() .minHlg() .minHxl()
.minH2xl() .minH3xl() .minH4xl() .minH5xl() .minH6xl() .minH7xl()
.maxH3xs() .maxH2xs() .maxHxs() .maxHsm() .maxHmd() .maxHlg() .maxHxl()
.maxH2xl() .maxH3xl() .maxH4xl() .maxH5xl() .maxH6xl() .maxH7xl()
// Position System
.position() // Enable positioning
.positionStatic() // Default positioning
.positionRelative() // Relative positioning
.positionAbsolute() // Absolute positioning
.positionFixed() // Fixed positioning
.positionSticky() // Sticky positioning
// Position Values (Tailwind-style)
.top0() .top1() .top2() .top4() .top(50) // Top positioning
.right0() .right1() .right2() .right4() .right(30) // Right positioning
.bottom0() .bottom1() .bottom2() .bottom4() .bottom(20) // Bottom positioning
.left0() .left1() .left2() .left4() .left(10) // Left positioning
// Inset Shortcuts
.inset0() .inset1() .inset2() .inset4() // All directions
.insetX0() .insetX1() .insetX2() // Horizontal (left + right)
.insetY0() .insetY1() .insetY2() // Vertical (top + bottom)
// Custom Positioning
.positioned(top: 20, left: 10, width: 200, height: 100)
// Interactions
.onTap(() {}) .onDoubleTap(() {}) .onLongPress(() {})
FlexBuilder Methods
// Direction
.flexRow() .flexCol()
// Main Axis Alignment
.justifyStart() .justifyEnd() .justifyCenter()
.justifyBetween() .justifyAround() .justifyEvenly()
// Cross Axis Alignment
.itemsStart() .itemsEnd() .itemsCenter()
.itemsStretch() .itemsBaseline()
// Flex Properties
.flex1() .flex2() .flex3() // Fixed flex values
.flexAuto() .flexNone() .flex(int) // Custom flex
// Gap (spacing between children)
.gap1() .gap2() .gap3() .gap4() .gap6() .gap8() .gap12() .gap16()
.gap(double) // Custom gap value
🔗 Method Chaining #
All builders support fluent method chaining:
Text('Hello')
.asText() // Convert to TextBuilder
.textBlue600() // Text styling
.fontBold() // More text styling
.asContainer() // Convert to ContainerBuilder
.px6() // Container styling
.py3() // More container styling
.bgWhite() // Background
.r8() // Border radius
.shadow() // Drop shadow
.onTap(() {}) // Interaction
// .build() called automatically when used
❓ FAQ #
Why use builder pattern instead of direct widget styling?
- Performance: Creates single optimized widgets instead of nested containers
- Readability: Self-documenting code that reads like CSS classes
- Type Safety: Full compile-time checking and IntelliSense support
- Maintainability: Consistent API across all styling needs
- Memory Efficiency: Reduced widget tree depth
How does this compare to other Flutter styling solutions?
Feature | TailwindCSS Build | Traditional Flutter | Other Packages |
---|---|---|---|
Code Length | 70% shorter | Verbose | Varies |
Performance | Single widgets | Nested containers | Varies |
Learning Curve | TailwindCSS knowledge | Flutter widgets | Package-specific |
Type Safety | Full | Full | Varies |
Customization | High | High | Limited |
Can I mix traditional Flutter widgets with builders?
Yes! Builders are designed to work seamlessly with existing Flutter code:
Column(
children: [
// Traditional Flutter
Container(
padding: EdgeInsets.all(16),
child: Text('Traditional'),
),
// TailwindCSS Build
Text('Modern')
.asText()
.textBlue600()
.asContainer()
.p4()
.bgGray100()
.build(),
],
)
Does this work with existing themes and styling?
Yes! The builders respect Flutter's theme system and can be combined with:
- Material Design themes
- Custom themes
- Dark/Light mode
- Custom color schemes
How do I handle responsive design?
Use Flutter's built-in responsive tools with builders:
LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth > 600) {
// Desktop layout
return [widgets].asFlex().flexRow().build();
} else {
// Mobile layout
return [widgets].asFlex().flexCol().build();
}
},
)
🔄 Migration Guide #
From 0.3.x to 0.4.0 #
API Changes
// ❌ Old way (0.3.x)
Text('Hello').textBlue600().fontBold().asContainer().px4().bgWhite()
// ✅ New way (0.4.0)
Text('Hello')
.asText()
.textBlue600()
.fontBold()
.asContainer()
.px4()
.bgWhite()
.build()
// ❌ Old method names
.asTextBuilder() → .asText()
.asContainerBuilder() → .asContainer()
// ✅ Simplified interactions
// Old: GestureDetector(onTap: ..., child: widget)
// New: widget.onTap(...)
🧪 Testing & Debugging #
🔍 Widget Inspector Integration #
// Each builder creates a single, inspectable widget
Text('Debug Me')
.asText()
.textRed600()
.asContainer()
.px4()
.py2()
.bgRed100()
.border()
.borderRed500()
.r4()
.build() // ← Single Container widget in inspector tree
🎨 Custom Extensions #
Brand Colors
// Define your brand colors
extension BrandColors on ContainerBuilder {
ContainerBuilder bgPrimary() => backgroundColor(Color(0xFF1E40AF));
ContainerBuilder bgSecondary() => backgroundColor(Color(0xFF7C3AED));
ContainerBuilder bgAccent() => backgroundColor(Color(0xFF059669));
}
// Usage
Text('Brand Button')
.asContainer()
.px6()
.py3()
.bgPrimary() // Custom brand color
.r8()
.build()
Custom Spacing
extension CustomSpacing on ContainerBuilder {
ContainerBuilder pSection() => padding(EdgeInsets.all(32));
ContainerBuilder pCard() => padding(EdgeInsets.all(16));
}
🤝 Contributing #
We welcome contributions! Since this is a pre-1.0.0 package:
- Check Issues: Look for existing issues or create new ones
- Discuss Changes: For major changes, please discuss first
- Follow Patterns: Use the established builder pattern architecture
- Add Tests: Include tests for new functionality
- Update Docs: Update documentation for new features
🌟 Community #
- 📖 Documentation: pub.flutter-io.cn/packages/tailwindcss_build
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments #
- Inspired by Tailwind CSS
- Built for the Flutter community
- Thanks to all contributors and users
Ready to revolutionize your Flutter development?
flutter pub add tailwindcss_build
Transform verbose Flutter code into elegant, maintainable, and performant UI declarations with TailwindCSS Build.