quirijngb / lazy-load-scrollview Goto Github PK
View Code? Open in Web Editor NEWA wrapper for a Flutter ScrollView which enables lazy loading
License: BSD 2-Clause "Simplified" License
A wrapper for a Flutter ScrollView which enables lazy loading
License: BSD 2-Clause "Simplified" License
When this widget is kept under RefreshIndicator widget, the pull to refresh doesn't work. Maybe the RefreshIndicator widget is not receiving the scroll notification.
It worked when I inverted the widgets i.e kept RefreshIndicator under LazyLoadScrollView widget.
Does it work with CustomScrollView and related SliverList?
I wrapped the CustomScrollView with the LazyLoadScrollView, but I can only obtain the first pagination.
After that the onEndOfPage method does not get called anymore.
As you know, StatefulWidget takes a lot of resources.
Is it possible to implement this library with StatelessWidget?
RfreshIndicator stops working when LazyLoadScrollView is added to the tree. This makes it really inconvenient as Most ListViews fetching data have a RefreshIndicator. It would be nice if RehreshIndicator still works with LazyLoad
Every time I call a function on onEndOfPage, it is resetting the whole page and starting from the first value. Any help will be appreciated.
Hi,
It work with NestedScrollView?
Thanks.
Migrate to null safety
this is how my widget tree looks
LazyLoadScrollView(
onEndOfPage: ( ) { }
child: SingleChildScrollView( //vertical scroll view
child : Column(
. . . . .
CarouselSlider ( //horizontalScrollview
. . . . .
),
),);
onEndOfPage gets triggered for horizontal scroll view too which is not ideal for pagination, which is what I'm using it for, I tried using different scorllControllers, but nothing seems to be working,
Is there any way I can make this work, or can this be implemented in the package?
Thanks.
on android there is no problem when on ios if fast scroll is not detected but if it is slow then it is detected
In Flutter Android everything is fine. But I tested it on a small Flutter Web project and the package didn't work. Do you have any special configuration?
There should be some indicator to show that more items are loading or list has been finished.
Hey there, recently I've been working on this package.. and I tried to put my ListView.builder inside the LazyLoadScrollView, OK that's worked fine.
BUT... when I tried to wrap my ListView.builder by RefreshIndicator it gives me an error and that because the child accepts only ScrollView Widget...
.
.
.
.
// rest of the code
return LazyLoadScrollView(
onEndOfPage: () {
BlocProvider.of<FetchProductsBloc>(context).add(
FetchProducts(count: 20),
);
},
child: ListView.builder(
itemCount: state.count,
itemBuilder: (context, index) {
return ListTile(
title: Text('Loaded Data $index'),
);
},
),
);
.
.
.
.
HOW can I wrap the (listview with lazy load scrollview) with a refresh indicator too??
Any solutions??
Will this work if I want to append previous data when scrolling towards the top?
Hi,
I've used this plugin inside of a StreamBuilder without issues however when I try to use it inside a custom StatefulWidget the onEndOfPage callback gets called more than once.
Here the example app,
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:lazy_load_scrollview/lazy_load_scrollview.dart';
main() {
runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('LazyLoading'),
),
body: Home(),
),
));
}
class Home extends StatefulWidget {
final int pageSize;
Home({this.pageSize = 10});
@override
State<StatefulWidget> createState() => HomeState();
}
class HomeState extends State<Home> {
List<Map> documents;
bool loading;
int currentPage;
Client client;
@override
void initState() {
super.initState();
documents = [];
loading = false;
currentPage = 0;
client = Client();
() async {
await _loadMore();
}();
}
// 'http://monster6.disco.unimib.it/API/documents/search/?s=informatica&paging=${widget.pageSize}&offset=${currentPage > 0 ? currentPage * widget.pageSize : ''}'
Future<void> _loadMore() async {
print('loading more!');
setState(() {
loading = true;
});
final response = await client.get(
Uri.http(
'monster6.disco.unimib.it',
'/API/documents/search',
{
's': 'informatica',
'paging': '${widget.pageSize}',
'offset':
currentPage > 0 ? '${currentPage * widget.pageSize + 1}' : null
},
),
);
print(jsonDecode(response.body));
final results = List<Map>.from(
jsonDecode(response.body)['documentsAleph']['documents']);
if (mounted) {
setState(() {
loading = false;
documents.addAll(results);
currentPage++;
});
}
}
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Positioned.fill(
child: LazyLoadScrollView(
child: ListView.builder(
itemCount: documents.length,
itemBuilder: (context, index) {
return AspectRatio(
aspectRatio: 2,
child: Card(
child: Text(documents[index]['title'] ?? 'null'),
),
);
},
),
onEndOfPage: () {
_loadMore();
},
scrollOffset: 600,
),
),
Positioned(
top: 0,
left: 0,
right: 0,
child: loading ? LinearProgressIndicator() : Container(),
),
],
);
}
}
Dears,
Is possible to work with SliverGrid?
Thanks to advance,
Hi please can you add a level depth check into _onNotifcation method.
If you have a list with animated widget that scroll vertically this method is calle endlessly and also _loadMore.
The changes to do are these:
At row 61 of lazy_load_scrollview.dart
if (widget.scrollDirection == notification.metrics.axis) {
should turn into
if (widget.scrollDirection == notification.metrics.axis && defaultScrollNotificationPredicate(notification)) {
This check if the scroll came from the real list scroll and not from a scrollable item into it.
Regards
Massimo
When scrolling and reaches the bottom, does infinite loop calls. Should verify if
position.pixels == position.maxScrollExtent and if true do another call.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.