super_list_view

Creator: coderz1093

Last updated:

0 purchases

super_list_view Image
super_list_view Images

Languages

Categories

Add to Cart

Description:

super list view

SUPER LIST VIEW #
With this Package you can have a dynamic super ListView Widget allows to you:

less code to create ListView
scroll to load Items
refresh and reUpdate ListViewItems with pulling top

Installation #
Run following command at terminal:
dart pub add super_list_view
copied to clipboard
or add this line to pubspec.yaml
dependencies:
super_list_view: ^0.0.1
copied to clipboard
then
flutter get pub
copied to clipboard
usage #
let's know what we need to build this widget:


listViewItems : a variable every time update with setState() It will stack to previous Data in ListViewItems so you should not add new data to previous data as follow. simple:if you wans show new items, just put new item in this variable with setState.


getListViewItems : a Function what load data and change listViewItems with setState(). it has just has one param page


page : what is page? its a value say to you, what you have to load from your api or etc.


SuperListView().build(): it has 3 params and rerutns your SuperListView.
a. context is your BuildContext for your View
b.listViewItems:your new items for your superListView
c.item builder: its a function has 3 params and returns a Widget which is your View per your items. we can see this function prams:


context: no need to explain :)


item: its your item for this index of your listViewItems.


index: your item counter


d. set: a callBackFunction runs when superListView want new
data. you can handle that just with a Function and its pareter is page what you can pass to getListViewItems function to load new data


refresh(): this method clear and refreshe your superListView.



import 'package:flutter/material.dart';
import 'package:flutter/SuperListView.dart';
.
.
.
class ThisState extends State {
List listViewItems = [];

@override
void initState() {
super.initState();
//get first data from api
getListViewItems(0);
}

getListViewItems(int page) async {
//this Function update and load ListViewItems from every where you want
//you have to update ListViewItem Variable here to effect to superListView with setState()
//Note: you have to just add NewItems to "ListViewItems",because SuperListView stack new data to old data
List res = Requst.fromSomeWhere();
setState(() {
listViewItems = res;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('title'),
),
body: SuperListView().build(context,
listViewItems,
(BuildContext context, item, index) {
//with this item you can access to data for this index of ListViewItems
retrun Text(index.toString()+ '. ' +item['name']);
}, (int page) {
//this function runs after ListView needed to load more data, its return page and you have to update "listViewItems" with setData method
getListViewItems(page);
}),
);
}
}

copied to clipboard
License #
MIT

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.