replace unnecesairy custom method with .take

This commit is contained in:
krawieck 2020-10-06 15:47:51 +02:00
parent c4ed57d393
commit 56a77187b9
1 changed files with 2 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import 'package:lemmy_api_client/lemmy_api_client.dart';
import 'package:url_launcher/url_launcher.dart' as ul; import 'package:url_launcher/url_launcher.dart' as ul;
import '../hooks/stores.dart'; import '../hooks/stores.dart';
import '../util/extensions/api.dart';
import '../util/goto.dart'; import '../util/goto.dart';
import '../util/text_color.dart'; import '../util/text_color.dart';
import '../widgets/badge.dart'; import '../widgets/badge.dart';
@ -352,7 +353,7 @@ class _AboutTab extends HookWidget {
), ),
), ),
if (commSnap.hasData) if (commSnap.hasData)
...commSnap.data.getRangeOrShorter(0, 6).map((e) => ListTile( ...commSnap.data.take(6).map((e) => ListTile(
onTap: () => onTap: () =>
goToCommunity.byId(context, e.instanceUrl, e.id), goToCommunity.byId(context, e.instanceUrl, e.id),
title: Text(e.name), title: Text(e.name),
@ -468,13 +469,3 @@ class _Divider extends StatelessWidget {
child: Divider(), child: Divider(),
); );
} }
extension GetRangeOrShorter on List {
Iterable getRangeOrShorter(int start, int end) {
if (length < end) {
return getRange(start, length);
} else {
return getRange(start, end);
}
}
}