Created
December 18, 2022 15:18
-
-
Save giuliano-macedo/a55030f7307c19d85e656059be39b6a4 to your computer and use it in GitHub Desktop.
A dart extension on a list of flutter widgets so that it can add padding between each one.
This file contains 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:collection/collection.dart'; | |
import 'package:flutter/material.dart'; | |
extension WidgetListSpacing on List<Widget> { | |
List<Widget> withSizedBoxBetween({double? width, double? height}) { | |
final box = SizedBox(width: width, height: height); | |
return mapIndexed((index, widget) => index == 0 || index == length ? [widget] : [box, widget]).flattened.toList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment