mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 15:08:18 -07:00
Init repo
This commit is contained in:
commit
764b6034e3
566 changed files with 212335 additions and 0 deletions
42
lib/util/list_padding.dart
Normal file
42
lib/util/list_padding.dart
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension ListExtensions on List<Widget> {
|
||||
addInBetween(Widget widget) {
|
||||
return mapIndexed(
|
||||
(index, element) {
|
||||
if (element != last) {
|
||||
return [element, widget];
|
||||
} else {
|
||||
return [element];
|
||||
}
|
||||
},
|
||||
).expand((element) => element).toList();
|
||||
}
|
||||
|
||||
addPadding(EdgeInsets padding) {
|
||||
return map((e) {
|
||||
if (e is Expanded || e is Spacer || e is Flexible) return e;
|
||||
return Padding(
|
||||
padding: padding.copyWith(
|
||||
top: e == first ? 0 : null,
|
||||
left: e == first ? 0 : null,
|
||||
right: e == last ? 0 : null,
|
||||
bottom: e == last ? 0 : null,
|
||||
),
|
||||
child: e,
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
addSize({double? width, double? height}) {
|
||||
return map((e) {
|
||||
if (e is Expanded || e is Spacer || e is Flexible) return e;
|
||||
return SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: e,
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue