dynamic list view
a list component that can refreshes and adds more data for flutter app.
installation
add this to your package’s pubspec.yaml file:
dependencies:
dynamic_list_view: ^0.1.5
list component usage example
import 'package:dynamic_list_view/dynamiclistview.dart';
import 'package:flutter/material.dart';
import 'dart:async';
void main() => runapp(myapp());
class myapp extends statefulwidget {
@override
_myappstate createstate() => _myappstate();
}
class _myappstate extends state<myapp> {
@override
widget build(buildcontext context) {
return materialapp(
home: scaffold(
body: container(
child: dynamiclistview.build(
itembuilder: _itembuilder,
datarequester: _datarequester,
initrequester: _initrequester,
),
),
),
);
}
future<list> _initrequester() async {
return future.value(list.generate(15, (i) => i));
}
future<list> _datarequester() async {
return future.delayed(duration(seconds: 2), () {
return list.generate(10, (i) => 15 + i);
});
}
function _itembuilder = (list datalist, buildcontext context, int index) {
string title = datalist[index].tostring();
return listtile(title: text("number $title"));
};
}
Comments are closed.