custom_loadmore 0.0.2
custom_loadmore: ^0.0.2 copied to clipboard
Package to assist load more, paging logic for your Flutter projects.
INTRODUCTION #
The custom_loadmore component is a convenient flutter widget that make implementation load more feature more easier, it provide a flexible and easy to use interface and can integrate with any Flutter project. This give developer focus more on another aspect when development feature also provide ability to control the layout and appearance of UI.
Features #
- Load more feature
- Layout modifies ability
- Handing build in ui function.
Installation #
To use this in your project, you need follow these steps:
- In your
pubspec.yamlfile add follow codes
dependencies:
custom_loadmore: ^0.0.2
-
Run
flutter pub get. -
Make sure import this file when use this package.
import 'package:custom_loadmore/custom_loadmore.dart'
Usage #
A longer example can be found in the /example folder.
Modifying the Layout #
To change the default layout behavior (the list view layout), follow these steps:
- Create new
classthatextend CustomScrollableLayoutBuilderInjector<T>. Then override thebuildMainContentmethod. This method return anCustomLoadMoreContent<T>that abstract the layout appearance. - Next you must create a specific implementation of
CustomLoadMoreContentwith scarify your demands by create a class thatextend CustomLoadMoreContent. The abstract class provide you some necessary property to build your layout.
items: TheList<T>where you can get the items need to use when build the item widget in the list. Usually it data come from the call to the server.mainAxisDirection: provide you the scroll direction.scrollController: support you the ability to manuals the scroll behavior.streamController: help you more convenience to change the state of load more widget.state: supplies you the current state of the widget.widget: provide you to accessibility to widget configuration where you can get all build delegate and other properties.
- Attach it new layout injector to
CustomLoadMore.
Here is example code that demonstrate these above step.
1.
class CustomScrollableListViewBuilderInjector<T>
extends CustomScrollableLayoutBuilderInjector<T> {
@override
CustomLoadMoreContent<T> buildMainContent(
BuildContext context,
LoadMoreState state,
List<T>? dataItems,
ScrollController scrollController,
StreamController<LoadMoreEvent> streamController,
) {
return LoadMoreList<T>(
widgetParent.key,
state: state,
mainAxisDirection: widgetParent.mainAxisDirection,
items: dataItems,
widget: widgetParent,
scrollController: scrollController,
streamController: streamController,
);
}
}
2.
class LoadMoreList<T> extends CustomLoadMoreContent<T>{
const LoadMoreList(super.key,
{required super.state,
required super.mainAxisDirection,
required super.items,
required super.scrollController,
required super.streamController,
required super.widget});
///
<!-- ...some other methods -->
///
@override
Widget build(BuildContext context){
return yourWidgetLayout(content);
}
}
3.
CustomLoadMore<T>(
customScrollableLayoutBuilderInjector: YourNewLayoutInjector(),
<!-- Some other properties -->
);