Created
June 29, 2021 07:25
-
-
Save nxcco/0e772ede42466df9ed0dd654df5f12cb to your computer and use it in GitHub Desktop.
Renewed version of the Column Builder for Flutter by @slightfoot. (Original: https://gist.github.com/slightfoot/a75d6c368f1b823b594d9f04bf667231)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/widgets.dart'; | |
class ColumnBuilder extends StatelessWidget { | |
final IndexedWidgetBuilder itemBuilder; | |
final MainAxisAlignment mainAxisAlignment; | |
final MainAxisSize mainAxisSize; | |
final CrossAxisAlignment crossAxisAlignment; | |
final TextDirection? textDirection; | |
final VerticalDirection verticalDirection; | |
final int itemCount; | |
const ColumnBuilder({ | |
Key? key, | |
required this.itemBuilder, | |
required this.itemCount, | |
this.mainAxisAlignment = MainAxisAlignment.start, | |
this.mainAxisSize = MainAxisSize.max, | |
this.crossAxisAlignment = CrossAxisAlignment.center, | |
this.verticalDirection = VerticalDirection.down, | |
this.textDirection, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return new Column( | |
children: new List.generate( | |
this.itemCount, (index) => this.itemBuilder(context, index)).toList(), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment