Line data Source code
1 : import 'package:flutter/material.dart'; 2 : 3 : /// Abstract class to implement mentioned methods 4 : /// [getChildAtIndex] 5 : /// [itemCount] 6 : abstract class LiquidSwipeChildDelegate { 7 : Widget getChildAtIndex(BuildContext context, int index); 8 : 9 : int itemCount(); 10 : } 11 : 12 : /// Extends [LiquidSwipeChildDelegate] to implement methods for List of Pages 13 : class LiquidSwipePagesChildDelegate extends LiquidSwipeChildDelegate { 14 : final List<Widget> pages; 15 : 16 1 : LiquidSwipePagesChildDelegate(this.pages); 17 : 18 1 : @override 19 : Widget getChildAtIndex(BuildContext context, int index) { 20 5 : if (index < 0 || index > pages.length - 1) { 21 0 : return ErrorWidget("index not in limit, index = $index"); 22 : } 23 2 : return pages[index]; 24 : } 25 : 26 1 : @override 27 : int itemCount() { 28 2 : return pages.length; 29 : } 30 : } 31 : 32 : /// Extends [LiquidSwipeChildDelegate] to implement methods for itemBuilder in [LiquidSwipe.builder(itemBuilder: itemBuilder, itemCount: itemCount)] 33 : class LiquidSwipeBuilderChildDelegate extends LiquidSwipeChildDelegate { 34 : final IndexedWidgetBuilder itemBuilder; 35 : 36 : final int itemCountQ; 37 : 38 0 : LiquidSwipeBuilderChildDelegate(this.itemBuilder, this.itemCountQ); 39 : 40 0 : @override 41 : Widget getChildAtIndex(BuildContext context, int index) { 42 0 : return itemBuilder(context, index); 43 : } 44 : 45 0 : @override 46 : int itemCount() { 47 0 : return itemCountQ; 48 : } 49 : }