turned spaced helper into a extension

This commit is contained in:
shilangyu 2020-10-23 00:38:25 +02:00
parent 5b5d65abce
commit b62ee7317a
3 changed files with 12 additions and 13 deletions

View File

@ -8,8 +8,8 @@ import '../hooks/logged_in_action.dart';
import '../hooks/memo_future.dart';
import '../hooks/stores.dart';
import '../util/extensions/api.dart';
import '../util/extensions/spaced.dart';
import '../util/goto.dart';
import '../util/spaced.dart';
import '../widgets/markdown_text.dart';
import 'full_post.dart';
@ -197,7 +197,7 @@ class CreatePost extends HookWidget {
),
body: SafeArea(
child: Column(
children: spaced(6, [
children: [
instanceDropdown,
communitiesDropdown,
url,
@ -226,7 +226,7 @@ class CreatePost extends HookWidget {
)
],
),
]),
].spaced(6),
),
),
);

View File

@ -0,0 +1,9 @@
import 'package:flutter/cupertino.dart';
/// Creates gaps between given widgets
extension SpaceWidgets on List<Widget> {
List<Widget> spaced(double gap) => expand((item) sync* {
yield SizedBox(width: gap, height: gap);
yield item;
}).skip(1).toList();
}

View File

@ -1,10 +0,0 @@
import 'package:flutter/cupertino.dart';
/// Creates gaps between given widgets
List<Widget> spaced(double gap, Iterable<Widget> children) => children
.expand((item) sync* {
yield SizedBox(width: gap, height: gap);
yield item;
})
.skip(1)
.toList();