Skip to content

Commit f914dfd

Browse files
committed
chore(project): Remove useless custom elementAtOrNull function
1 parent 39495a0 commit f914dfd

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

Diff for: lib/src/helper.dart

-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ extension CustomList<T> on List<T> {
22
List<T> asReversed(bool isReverse) {
33
return isReverse ? reversed.toList() : this;
44
}
5-
6-
T? elementAtOrNull(int index) {
7-
try {
8-
return this[index];
9-
} catch (_) {}
10-
return null;
11-
}
125
}
136

147
bool isBackgroundImageAssetPathValid(String assetPath) {

Diff for: lib/src/introduction_screen.dart

+5-4
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,9 @@ class IntroductionScreenState extends State<IntroductionScreen> {
548548
Widget? leftBtn;
549549
// show skip button when skip is enabled and back is disabled,
550550
// or show it on the first page when back is enabled.
551-
if (widget.showSkipButton && ((getCurrentPage() == 0 && widget.showBackButton) || !widget.showBackButton)) {
551+
if (widget.showSkipButton &&
552+
((getCurrentPage() == 0 && widget.showBackButton) ||
553+
!widget.showBackButton)) {
552554
leftBtn = Visibility(
553555
visible: !isLastPage && !_isSkipPressed,
554556
maintainState: true,
@@ -604,9 +606,8 @@ class IntroductionScreenState extends State<IntroductionScreen> {
604606
final pages = widget.pages
605607
?.mapIndexed((index, page) => IntroPage(
606608
page: page,
607-
scrollController: CustomList(
608-
widget.scrollControllers,
609-
)?.elementAtOrNull(index),
609+
scrollController:
610+
widget.scrollControllers?.elementAtOrNull(index),
610611
))
611612
.toList() ??
612613
widget.rawPages!;

Diff for: test/src/helper_test.dart

-12
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,5 @@ void main() {
1313
test('asReversed() returns original list when isReverse is false', () {
1414
expect(originalList.asReversed(false), [1, 2, 3, 4, 5]);
1515
});
16-
17-
test('elementAtOrNull returns the correct element for valid index', () {
18-
expect(originalList.elementAtOrNull(1), 2);
19-
});
20-
21-
test('elementAtOrNull returns null for out of bounds index', () {
22-
expect(originalList.elementAtOrNull(5), isNull);
23-
});
24-
25-
test('elementAtOrNull returns null for negative index', () {
26-
expect(originalList.elementAtOrNull(-1), isNull);
27-
});
2816
});
2917
}

0 commit comments

Comments
 (0)