Giter Club home page Giter Club logo

flutter_pagewise's People

Contributors

abdulrahmanalhamali avatar sjmcdowall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_pagewise's Issues

Suggestion: use controller pattern

The plugin works nice but it would be good to have info have many pages have been loaded, etc. Also setup is kind of annoying because you have to pass bunch of callback which are dynamic for some reason.

Flutter uses Controller pattern, for example TextEditingController that stores this kind of data, so that it can be accessed from other widges. Something like this would probably work:

abstract class PageLoaderController<T> extends ChangeNotifier {
  Future<List<dynamic>> loadPage(int index);
  int get totalCount;
  int get pageSize;
}

Future<int> to int for totalCount

totalCount just accepts an int and I need to get this value from an external source (JSON result for a query to a DB).

This problem happens using an extended class of SearchDelegate.

@override Widget buildResults(BuildContext context) { // TODO: implement buildResults return PagewiseGridView( pageSize: 10, totalCount: BackendService.getSearchTotals(query), crossAxisCount: 2, mainAxisSpacing: 10.0, crossAxisSpacing: 5.0, //childAspectRatio: 0.802, padding: EdgeInsets.all(5.0), itemBuilder: _itemBuilder, pageFuture: (pageIndex){ return BackendService.getSearchItems(pageIndex, query); }, ); }

if I change totalCount: BackendService.getSearchTotals(query) to totalCount: 20 it works but I need the exact total of Items.

How can I solve this?

can provide load more builder ?

In my app, initial loading style is different from load more style. Now only provide loadingBuilder, I should judge by myself. That nice if can provide a load more builder.

Dynamic constructor parameters aren't helpful

First of all, thank you for this amazing library!

Constructors of PagewiseListView have only dynamic values while I see that Pagewise base class has them all properly typed. The fact that the class which is exposed to us doesn't have types for its parameters is not the best thing. Is it possible to add types even to the classes extending Pagewise?

Exception thrown on scrolling

Scrolling down and then up causes the following exception to be thrown

I/al.openbook.de(17067): Waiting for a blocking GC ProfileSaver
I/al.openbook.de(17067): WaitForGcToComplete blocked ProfileSaver on ProfileSaver for 18.457ms
I/flutter (17067): Loading with index1
I/flutter (17067): Loading with index2
I/flutter (17067): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (17067): The following assertion was thrown during performLayout():
I/flutter (17067): A RenderViewport exceeded its maximum number of layout cycles.
I/flutter (17067): RenderViewport render objects, during layout, can retry if either their slivers or their
I/flutter (17067): ViewportOffset decide that the offset should be corrected to take into account information collected
I/flutter (17067): during that layout.
I/flutter (17067): In the case of this RenderViewport object, however, this happened 10 times and still there was no
I/flutter (17067): consensus on the scroll offset. This usually indicates a bug. Specifically, it means that one of the
I/flutter (17067): following three problems is being experienced by the RenderViewport object:
I/flutter (17067):  * One of the RenderSliver children or the ViewportOffset have a bug such that they always think
I/flutter (17067):    that they need to correct the offset regardless.
I/flutter (17067):  * Some combination of the RenderSliver children and the ViewportOffset have a bad interaction such
I/flutter (17067):    that one applies a correction then another applies a reverse correction, leading to an infinite
I/flutter (17067):    loop of corrections.
I/flutter (17067):  * There is a pathological case that would eventually resolve, but it is so complicated that it
I/flutter (17067):    cannot be resolved in any reasonable number of layout passes.
I/flutter (17067): 
I/flutter (17067): When the exception was thrown, this was the stack:
I/flutter (17067): #0      RenderViewport.performLayout.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1249:9)
I/flutter (17067): #1      RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1269:6)
I/flutter (17067): #2      RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (17067): #3      PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (17067): #4      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (17067): #5      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (17067): #6      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (17067): #7      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (17067): #8      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (17067): #9      _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (17067): #10     _invoke (dart:ui/hooks.dart:154:13)
I/flutter (17067): #11     _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter (17067): 
I/flutter (17067): The following RenderObject was being processed when the exception was fired:
I/flutter (17067):   RenderViewport#58d0d NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):   creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#99acc] ← Semantics ← Listener ←
I/flutter (17067):   _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#f5978] ←
I/flutter (17067):   _ScrollSemantics-[GlobalKey#df4c1] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter (17067):   NotificationListener<ScrollNotification> ← ⋯
I/flutter (17067):   parentData: <none> (can use size)
I/flutter (17067):   constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=565.4)
I/flutter (17067):   layer: OffsetLayer#82aa5
I/flutter (17067):   size: Size(411.4, 565.4)
I/flutter (17067):   axisDirection: down
I/flutter (17067):   crossAxisDirection: right
I/flutter (17067):   offset: ScrollPositionWithSingleContext#108c9(offset: 604.7, range: 0.0..5459.8, viewport: 565.4,
I/flutter (17067):   ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics,
I/flutter (17067):   BallisticScrollActivity#e8181(AnimationController#fa432(▶ 604.710; for BallisticScrollActivity)),
I/flutter (17067):   ScrollDirection.forward)
I/flutter (17067):   anchor: 0.0
I/flutter (17067): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (17067):   RenderSliverPadding#6aed6 relayoutBoundary=up1 NEEDS-PAINT
I/flutter (17067):     RenderSliverList#244b5 relayoutBoundary=up2 NEEDS-PAINT
I/flutter (17067):       RenderIndexedSemantics#ef6a9 relayoutBoundary=up3 NEEDS-PAINT
I/flutter (17067):         RenderRepaintBoundary#454ba relayoutBoundary=up4 NEEDS-PAINT
I/flutter (17067):           RenderFlex#9d270 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (17067):       RenderIndexedSemantics#75d75 relayoutBoundary=up3
I/flutter (17067):         RenderRepaintBoundary#ee7fa relayoutBoundary=up4
I/flutter (17067):           RenderFlex#dd278 relayoutBoundary=up5
I/flutter (17067):       RenderIndexedSemantics#da148 relayoutBoundary=up3
I/flutter (17067):         RenderRepaintBoundary#cd0f4 relayoutBoundary=up4
I/flutter (17067):           RenderFlex#28339 relayoutBoundary=up5
I/flutter (17067):       RenderIndexedSemantics#8d22e relayoutBoundary=up3
I/flutter (17067):         RenderRepaintBoundary#85151 relayoutBoundary=up4
I/flutter (17067):           RenderFlex#044e1 relayoutBoundary=up5
I/flutter (17067):       RenderIndexedSemantics#f6f71 NEEDS-LAYOUT
I/flutter (17067):         RenderRepaintBoundary#b6744 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):           RenderFlex#ec9dc NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):       RenderIndexedSemantics#a3b06 NEEDS-LAYOUT
I/flutter (17067):         RenderRepaintBoundary#c4ffe NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):           RenderFlex#7e732 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):       RenderIndexedSemantics#84037 NEEDS-LAYOUT
I/flutter (17067):         RenderRepaintBoundary#d9b0e NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):           RenderFlex#f8570 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):       RenderIndexedSemantics#1b234 NEEDS-LAYOUT
I/flutter (17067):         RenderRepaintBoundary#d4b6f NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):           RenderFlex#b7edc NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):       RenderIndexedSemantics#3edca NEEDS-LAYOUT
I/flutter (17067):         RenderRepaintBoundary#12a75 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067):           RenderFlex#fcaa5 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (17067): ════════════════════════════════════════════════════════════════════════════════════════════════════

Item Redundant

Hello,

I have list with item as below:

  • a
  • b
  • c

and then i am request to load 3 more data using pagewise and the result is below:

  • d
  • e
  • f

but why in my list it's shown as

  • a
  • b
  • c
  • c
  • d
  • e
  • f

sometime it's shown the right result, but sometime it's shown the redundant, and the reduntant item it's always the last item on the requested list. thank you

How to center loadingBuilder content

I've got a PagewiseListView being rendered inside a RefreshIndicator, which looks something like:

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: RefreshIndicator(
      onRefresh: () async { 
       /* code here */
      },
      child: PagewiseListView(
        pageLoadController: _pageLoadController,
        loadingBuilder: (context) => Center(child: CircularProgressIndicator()),
        itemBuilder: (context, Call item, index) {
          /* code here */
        }
      )
    )
  );
}

I can't get the CircularProgressIndicator within the loadingBuilder render method to centre vertically (it centers horizontally ok). I've tried wrapping it around containers, stacks and a few other things but none of them seem to want to center in the middle of the screen.

Any hints on how to get this working?

New version 1.2.0 integration with Wordpress

Hi guys,
I've checked Your new version and it's a little confusing for me. Could You please explain me how do I integrate this with a JSON request that is paginated?
What I mean is that I have a JSON request that should pull 1243 results, but I don't want then to be loaded at once. So the JSON request is called every time I get to the end of the 10 results I just pulled.

Does it make sense?

Thanks for Your time!

(PagewiseGridView) loadingBuilder shows less than expected

Hi Abdul,
First, thanks for this wonderful library. I, however, can't seem to get loadingBuilder to work as I want it to.

In particular, I want to show a 2 x 5 grid of Card elements. Hence, I have defined the following

body: PagewiseGridView.count(
   crossAxisCount: 2,
   pageLoadController: <something>,
   itemBuilder: <something>,
   loadingBuilder: (context) => GridView.count(
       crossAxisCount: 2, 
       children: List<Widget>.generate(10, (j) => EmptyCard()),
   ), 
)

What I get instead is a 1 x 2 row of EmptyCard. What should my loading widget be so that _getStandardContainer() expands to show a 2 x 5 grid? I have tried Column, Row etc. - but to no avail

Thanks
Abhinav

initial load not triggered, ListView

Greetings,

The package seems to be working very well for me except for one issue: The list is initially blank and I have to click the retry button to force the initialization (pageFuture for page 0).
After that, it pageFuture works just fine.

Is there a method to force initialization? Or am I doing something wrong?

Thanks.

Here is my code:

// .. Stateful widget...

class _EntriesState extends State<Entries> {
  static const PAGE_SIZE = 3;
  LabeledEntriesModel _model;  // a ScopedModel
  List<Entry> _entries = [];

  Future<List<Entry>> _getEntries(pageIndex) async {
    int offset = pageIndex * PAGE_SIZE;
    int limit = PAGE_SIZE;
    return _entries.sublist(offset, offset + limit);
  }

  Widget _buildEntryList(LabeledEntriesModel model) {
    return PagewiseListView(
      pageSize: PAGE_SIZE,
      padding: EdgeInsets.all(15.0),
      itemBuilder: (context, item, index) => EntryCard(entry: item),
      pageFuture: (pageIndex) => _getEntries(pageIndex),
    );
  }

  @override
  Widget build(BuildContext context) {
    return ScopedModelDescendant<LabeledEntriesModel>(
      builder: (context, Widget child, LabeledEntriesModel model) {
        _model = model;
        _entries = _model.entriesForLabel(_model.curLabel);
        return _buildEntryList(model);
      },
    );
  }
}

Stop scrolling until next page is loaded!

Hey , loved your plugin ! I have a doubt.

Suppose my pagesize is 10 items and after scrolling through 10 items I need to wait for another 10 items to load but unless they are loaded I cannot scroll . Is there any way to achieve this using pagewise .

Unhandled Exception: A PagewiseLoadController<Log> was used after being disposed.

Hi,

i got an app with a tabbed navigation. When i switch tabs (where one tab contains a PagewiseSliverList) very fast i get following exception:

	Once you have called dispose() on a PagewiseLoadController<Log>, it can no longer be used.
	#0      ChangeNotifier._debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:105:9)
	#1      ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:111:6)
	#2      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:200:12)
	#3      PagewiseLoadController.fetchNewPage (package:flutter_pagewise/flutter_pagewise.dart:497:7)
	<asynchronous suspension>
	#4      PagewiseState._itemBuilder (package:flutter_pagewise/flutter_pagewise.dart:270:35)
	#5      SliverChildBuilderDelegate.build (package:flutter/src/widgets/sliver.dart:398:15)
	#6      SliverMultiBoxAdaptorElement._build.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1006:67)
	#7      _HashMap.putIfAbsent (dart:collection-patch/collection_patch.dart:137:29)
	#8      SliverMultiBoxAdaptorElement._build (package:flutter/src/widgets/sliver.dart:1006:26)
	#9      SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1019:55)
	#10     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2258:19)
	#11     SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1012:11)
	#12     RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:275:23)
	#13     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1740:58)
	#14     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:797:15)
	#15     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1740:13)
	#16     RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:264:5)
	#17     RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:348:5)
	#18     RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:78:12)
	#19     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#20     RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182:11)
	#21     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#22     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:407:13)
	#23     RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1322:12)
	#24     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1240:20)
	#25     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#26     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
	#27     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#28     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
	#29     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#30     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
	#31     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#32     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
	#33     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#34     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
	#35     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#36     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
	#37     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#38     RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
	#39     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#40     RenderSliverFillRemaining.performLayout (package:flutter/src/rendering/sliver_fill.dart:122:13)
	#41     RenderObject.layout (package:flutter/src/rendering/object.dart:1644:7)
	#42     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:407:13)
	#43     RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1322:12)
	#44     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1240:20)
	#45     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1519:7)
	#46     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:766:18)
	#47     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:347:19)
	#48     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
	#49     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
	#50     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15)
	#51     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9)
	#52     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:864:5)
	#53     _rootRun (dart:async/zone.dart:1124:13)
	#54     _CustomZone.run (dart:async/zone.dart:1021:19)
	#55     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
	#56     _invoke (dart:ui/hooks.dart:219:10)
	#57     _drawFrame (dart:ui/hooks.dart:178:3)

Since this only occurs if the switch is really fast it is not that big issue.
I tried checking if the PagewiseLoadController is null before using it (and set it to null after disposing), but it did not help. So i guess solely setting up the Controller in initState() and immediately dispose it after that (via a fast tab switch) is causing this exception. (I am really new to flutter, so this may be completely wrong :) )

Length called on Null ERROR

I followed the examples stated carefully but each time I try to use the plugin, my future completes with data successfully(i could log them to console ) but then I get the length called on Null error. On checking error stack It pointed to a line With

Page.lenght <= another test case here

But looking at this plugin, there's no provision for page length, So definitely that value might just b null, or is there something I am missing ?

Also my Code is almost as exact as your example below .
`Class PagewiseListViewExample extends StatelessWidget {
static const int PAGE_SIZE = 10;

@OverRide
Widget build(BuildContext context) {
return PagewiseListView(
pageSize: PAGE_SIZE,
itemBuilder: this._itemBuilder,
pageFuture: (pageIndex) =>
BackendService.getPosts(pageIndex * PAGE_SIZE, PAGE_SIZE));
}

Widget _itemBuilder(context, PostModel entry, _) {
return Column(
children: [
ListTile(
leading: Icon(
Icons.person,
color: Colors.brown[200],
),
title: Text(entry.title),
subtitle: Text(entry.body),
),
Divider()
],
);
}
}`

'(BuildContext, dynamic, int) => dynamic' is not a subtype of type '(BuildContext, dynamic, int) => Widget'.

Returning post.test() in itemBuilder() yields the following error. I cannot seem to get pass it other than constructing the widget in the same class as the pagewise Widget instead of the the Post widget.

post.dart

import 'package:flutter/material.dart';
import 'package:shannon/comment_page.dart';

class Post {
  final String id;
  final String content;
  final double latitude;
  final double longitude;
  final int time;
  final String username;

  Post({this.id, this.content, this.latitude, this.longitude, this.time, this.username});

  factory Post.fromJson(Map<String, dynamic> json) {
    print(json['content']);
    return Post(
      id: json ['id'],
      content: json['content'],
      latitude: json['latitude'],
      longitude: json['longitude'],
      time: json['time'],
      username: json['username'],
    );
  }

  Widget test(){
    return ListTile(title: Text("A"));
  }
}
Performing hot restart...
Restarted application in 2,556ms.
I/flutter ( 5696): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 5696): The following assertion was thrown building FeedPage(dirty, state: _FeedPage#5841c):
I/flutter ( 5696): type '(BuildContext, dynamic, int) => dynamic' is not a subtype of type '(BuildContext, dynamic,
I/flutter ( 5696): int) => Widget'
I/flutter ( 5696):
I/flutter ( 5696): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 5696): more information in this error message to help you determine and fix the underlying cause.
I/flutter ( 5696): In either case, please report this assertion by filing a bug on GitHub:
I/flutter ( 5696):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter ( 5696):
I/flutter ( 5696): When the exception was thrown, this was the stack:
I/flutter ( 5696): #0      new PagewiseListView (package:flutter_pagewise/flutter_pagewise.dart:505:26)
I/flutter ( 5696): #1      _FeedPage.build (package:shannon/feed_page.dart:75:13)
I/flutter ( 5696): #2      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter ( 5696): #3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter ( 5696): #4      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 5696): #5      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 5696): #6      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 5696): #7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 5696): #8      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 5696): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 5696): #10     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 5696): #11     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 5696): #12     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2286:33)
I/flutter ( 5696): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:676:20)
I/flutter ( 5696): #14     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter ( 5696): #15     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 5696): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 5696): #17     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
I/flutter ( 5696): #19     _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter ( 5696): #20     _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter ( 5696): #21     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter ( 5696): (elided one frame from package dart:async)
I/flutter ( 5696): ════════════════════════════════════════════════════════════════════════════════════════════════════

Page wise controller reset does not return a Future

In the readme its stated that the reset method could be used together with the RefreshIndicator, the refresh indicator however expects the onRefresh method to return a Future. The PagewiseLoadController reset methods returns void as contrary to the example in the readme.

Extra padding underneath

I want to create a grid with exactly 3 items in 1 row.

For pageFuture, I use _fetcher(0).then((l) => l.take(3).toList())) to guarantee that it returns exactly three items.

PagewiseGridView.count(
	crossAxisCount: 3,
	itemBuilder: this._itemBuilder,
	pageFuture: this._fetcher,
	pageSize: 20,
	shrinkWrap: true,
)

But the displayed grid will always have a huge padding underneath, as if there's a 4th blank item wrapped, even though in the inspector, there are exactly three items.

img_0852

widget cannot be marked as needing to build because the framework is already in the process of building widgets

I get the following exception when trying to implement your example in my app

I/flutter (14463): ══╡ EXCEPTION CAUGHT BY FOUNDATION LIBRARY ╞════════════════════════════════════════════════════════
I/flutter (14463): The following assertion was thrown while dispatching notifications for
I/flutter (14463): PagewiseLoadController<dynamic>:
I/flutter (14463): setState() or markNeedsBuild() called during build.
I/flutter (14463): This PagewiseListView<dynamic> widget cannot be marked as needing to build because the framework is
I/flutter (14463): already in the process of building widgets. A widget can be marked as needing to be built during the
I/flutter (14463): build phase only if one of its ancestors is currently building. This exception is allowed because
I/flutter (14463): the framework builds parent widgets before children, which means a dirty descendant will always be
I/flutter (14463): built. Otherwise, the framework might not visit this widget during this build phase.
I/flutter (14463): The widget on which setState() or markNeedsBuild() was called was:
I/flutter (14463):   PagewiseListView<dynamic>(state: PagewiseState<dynamic>#dafc8)

Dart SDK version Error

Running "flutter packages get" in app...
The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.

Because app depends on flutter_pagewise >=1.2.2 which requires SDK version >=2.1.0 <3.0.0, version solving failed.

pub get failed (1)

[Question] Failing tests

Hey guys,
Thanks for this cool library. I'm using it and i want to write WidgetTests for my app. The following shows a minimal working example of the app. Unfortunately my test is failing and i don't understand why. Can you help me by explaining why? How do i get my test running?

My App:

import 'package:flutter/material.dart';
import 'package:flutter_pagewise/flutter_pagewise.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: PageWiseWidget()
    );
  }
}

class PageWiseWidget extends StatefulWidget{
  @override
  PageWiseWidgetState createState() {
    return PageWiseWidgetState();
  }
}

class PageWiseWidgetState extends State<PageWiseWidget> {
  @override
  Widget build(BuildContext context) {
    return
      Column(
          children: [
            Expanded(
                child: PagewiseListView(
                  pageFuture: BackendService.getPage,
                  pageSize: 10,
                  itemBuilder: (context, entry, _) => Text(entry['name']),
                )
            ),
          ]
      );
  }
}

class BackendService {
  static Future<List> getPage(pageIndex) async {
    List list = List.generate(pageIndex < 6 ? 10 : 5, (index) {
      int dataNumber = index + pageIndex * 10;
      return {
        'name': 'product' + dataNumber.toString(),
      };
    });
    return list;
  }
}

The failing test:


import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:page_wise_test/main.dart';

void main() {
  testWidgets('Elements are shown', (WidgetTester tester) async {
    // Build our app and trigger a frame.
    await tester.pumpWidget(StatefulBuilder(
        builder: (BuildContext context, StateSetter setState) {
          return MaterialApp(
            home: Material(
                child: PageWiseWidget()
            ),
          );
        })
    );
    expect(find.text('product3'), findsOneWidget);
  });
}

The error message is:

The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: ?:<zero widgets with text "product3" (ignoring offstage widgets)>
   Which: means none were found but one was expected

Do you have any idea why the product is shown in the running app but is not visible during the tests?
Thanks a lot :)

Error occurs while still loading page and push to another page

flutter: ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following NoSuchMethodError was thrown during a scheduler callback:
flutter: The method 'visitChildren' was called on null.
flutter: Receiver: null
flutter: Tried calling: visitChildren(Closure: (Element) => Null)
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
flutter: #1 _AutomaticKeepAliveState._getChildElement (package:flutter/src/widgets/automatic_keep_alive.dart:127:13)
flutter: #2 _AutomaticKeepAliveState._addClient. (package:flutter/src/widgets/automatic_keep_alive.dart:92:79)
flutter: #3 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
flutter: #4 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:938:9)
flutter: #5 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
flutter: #6 _invoke (dart:ui/hooks.dart:120:13)
flutter: #7 _drawFrame (dart:ui/hooks.dart:109:3)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: NoSuchMethodError: The method 'visitChildren' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The method 'visitChildren' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The method 'visitChildren' was called on null.

home route quirk

Greetings,
I opened an issue earlier today but then closed it when I realized that it was a flutter isssue, not a flutter_pagewise issue.

However, this may help you:

Flutter seems to initialize the home route in parallel with the main widget initialization.

Therefore, if you happen to be using a PagewiseListView on your home route, then PagewiseListview will attempt to render, but finding an empty list of entries, will show only the retry button.

 child: MaterialApp(
        home: EntriesPage(),   // problem if this widget contains a PagewiseListView
        routes: {
        //...
        }

So, probably what I will do is show a splash screen until data is initialized.
Hope this helps,
DA

Providing own PagewiseLoadController and using reset() messes up PageIndex

Hey there!

First of all, this is an awesome package! It has really saved me a ton of work. Thank you very much for the work you have done.

However, I have run into some problems using this package. I have recently changed my code so that my list (using Pagewise) is now using my own PagewiseLoadController that I have stored in a scoped model. I have done this in order to be able to reset the list/controller when I change an aspect of whatever should be fetched and displayed in the list (I'm making a simple movie app, and when I change the category of movies to fetch, I have to reset the Pagewise controller so that it can start over and start with the future that is now fetched using the new category).

When the app is first started there's no problems, and scrolling down fetches the next pages as expected. However, the problem occurs when I change the category (thereby also calling myPageWiseController.reset() ), which then fetches the first page with the new category correctly, but scrolling down makes the first fetched page loop, so that its basically just an infinite list of the movies from the first fetched page displaying over and over.

I've tried printing the PageIndex whenever a new fetch occurs from scrolling to the bottom, and I can see that the PageIndex stops incrementing after I change the category and reset the controller, but before that (when the app is first started) it increments totally fine. A look at the debug console shows the following:

Launching lib\main.dart on Pixel in debug mode...
Built build\app\outputs\apk\debug\app-debug.apk.
I/flutter ( 4688): 1
I/flutter ( 4688): 2
I/flutter ( 4688): 3
I/flutter ( 4688): 4
I/flutter ( 4688): 5

Here I change the category to something else than what the app initially starts with.

I/flutter ( 4688): 1

Initially it fetches the first page fine, as shown by the 1 above, but after scrolling to the bottom, the following is printed.

I/chatty ( 4688): uid=10369(com.example.myapp) 1.ui identical 7 lines
I/flutter ( 4688): 1

I don't know why that 1 above shows, it is not because of any change in the app, other than scrolling, the category is still the same.

When I change the category to something else again, the 1 below is shown and the first page with the new category is fetched normally, after which the same error shows up.

I/flutter ( 4688): 1
I/chatty ( 4688): uid=10369(com.example.myapp) 1.ui identical 8 lines
Application finished.
Exited (sigint)

Here is the relevant code:

My own PageWiseLoadController setup:

pageLoadController = PagewiseLoadController(
      pageSize: 20,
      pageFuture: (int pageIndex) => fetchMovies(pageIndex),
    );

Resetting the controller/list:

void resetList() {
    _pageLoadController.reset();
  }

The fetchMovies method (I'm incrementing the pageIndex, simply because the pageIndex starts at 0 but I have to start it at 1 for the fetching to work):

Future<List<Results>> fetchMovies(int pageIndex) async {
    pageIndex++;
    print(pageIndex);

    String category = (_categoryNow != null) ? _categoryNow.path : "popular";
    String url = "$baseUrl$category?api_key=$apiKey&page=$pageIndex&region=$_region";

    var response = await http.get(url);
    var decodeJson = jsonDecode(response.body);

    Movie newContent = Movie.fromJson(decodeJson);
    return newContent.results;
  }

My widget for the list:

class ContentList extends StatelessWidget {
  Widget build(BuildContext context) {
    return ScopedModelDescendant<ContentModel>(
      builder: (context, child, model) {
        return PagewiseListView(
          pageLoadController: model.pageLoadController,
          itemBuilder: (context, entry, _) => MovieCard(entry),
          noItemsFoundBuilder: (context) => Text('No Items Found'),
          retryBuilder: (context, callback) {
            return RaisedButton(
              child: Text('Retry'),
              onPressed: () => model.resetList(),
            );
          },
        );
      },
    );
  }
}

I've tried to describe the issue as best as I can, and hopefully I provided enough information/code for you to understand it.

Change Page Index

I want to change PageIndex to start from 1 instead of 0

PagewiseListView(
pageSize: PAGE_SIZE,
pageFuture: (pageIndex) =>
db.getAds(pageIndex * PAGE_SIZE, PAGE_SIZE),
itemBuilder: (context, i, _) {
return Container(
child: Card(
elevation: 6,
child: Padding(
padding: EdgeInsets.all(15.0),
child: ListTile(
leading: Text('${i['id']}'),
subtitle: Text('${i['content']}'),
),
),
)
);

PagewiseLoadController<dynamic>

I got this error.

flutter: #125    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame 
package:flutter/…/widgets/binding.dart:701
flutter: #126    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback 
package:flutter/…/rendering/binding.dart:268
flutter: #127    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback 
package:flutter/…/scheduler/binding.dart:988
flutter: #128    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame 
package:flutter/…/scheduler/binding.dart:928
flutter: #129    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame 
package:flutter/…/scheduler/binding.dart:840
flutter: #133    _invoke (dart:ui/hooks.dart:209:10)
flutter: #134    _drawFrame (dart:ui/hooks.dart:168:3)
flutter: (elided 4 frames from package dart:async)
flutter:
flutter: The PagewiseLoadController<dynamic> sending notification was:
flutter:   Instance of 'PagewiseLoadController<dynamic>'
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════

I have a simple implementation to which I just have

Widget build(BuildContext context) {
    return PagewiseListView(
      pageSize: limit,
      itemBuilder: (context, entry, _) {
        AttendeeModel attendee = entry;
        return _buildAttendee(context, attendee);
      },
      pageFuture: (index) =>
          this.attendeeBloc.getAttendees(context, (index * limit)),
      loadingBuilder: (context) => LoadingMask(),
    );
  }

[ASK] Add/remove item and edit existing item

Let me know if you prefer this to be in StackOverflow (posted here because it's a niche library).

Imagine you're building a Facebook clone, with flutter_pagewise powering the infinite scrolling of the wall. For each item, the user might want to tap to open the detail, and comment/like there. The user can also comment/like the item without going into the detail screen (that is, straight from the wall screen). Either way, the changes (e.g "liked" and first few comments) should be visible on the wall without reloading everything and losing scroll position.

The user can also create a new post, and immediately shown at the top of the wall. Also, hide/remove a post.

My question: How should I architect this best without fighting the framework? Specifically, now to add/remove/edit elements already "loaded"?

(There's already a similar issue: #55 I'm just presenting a broader use case).

exception if there is only items <= pageSize

This pluginn is working great except this exception where there is one one item

Code:-

return Scaffold(
      backgroundColor: Colors.white,
      appBar: new AppBar(
        centerTitle: true,
        title: new Text(
          widget.category.name,
          style: TextStyle(fontWeight: FontWeight.normal),
        ),
        leading: IconButton(
          icon: Icon(Icons.arrow_back_ios),
          onPressed: () => Navigator.of(context).pop(),
        ),
        actions: [
          PopupMenuButton<SortBy>(
            icon: Icon(Icons.sort_by_alpha),
            onSelected: changeSort,
            itemBuilder: (BuildContext context) => <PopupMenuItem<SortBy>>[
                  PopupMenuItem<SortBy>(
                    value: SortBy.AZ,
                    child: Text("A - Z"),
                  ),
                  PopupMenuItem<SortBy>(
                    value: SortBy.ZA,
                    child: Text("Z - A"),
                  ),
                ],
            elevation: 10.0,
            tooltip: "Sort By",
          ),
        ],
      ),
      body: Container(
        color: Colors.white,
        child: PagewiseGridView.count(
          crossAxisCount:
              MediaQuery.of(context).orientation == Orientation.portrait
                  ? 2
                  : 4,
          mainAxisSpacing: 4.0,
          crossAxisSpacing: 4.0,
          itemBuilder: (context, entry, _) {
            return ProductCard(entry);
          },
          pageLoadController: pageLoadController,
          childAspectRatio: 1.0,
          noItemsFoundBuilder: (context) {
            return Container(
              color: Colors.white,
              child: Center(
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Icon(
                        Icons.device_unknown,
                        color: Colors.black26,
                        size: 24,
                      ),
                    ),
                    Text(
                      "No products matching to this criteria",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        color: Colors.black26,
                      ),
                    ),
                  ],
                ),
              ),
            );
          },
          showRetry: true,
          loadingBuilder: (context) {
            return Row(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                CircularProgressIndicator(),
                SizedBox(
                  width: 20.0,
                ),
                Text('Loading...'),
              ],
            );
          },
        ),
      ),
    );

Exception Log:-
I/flutter (25161): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (25161): The following assertion was thrown during performLayout():
I/flutter (25161): SliverGeometry is not valid: The "maxPaintExtent" is less than the "paintExtent".
I/flutter (25161): The maxPaintExtent is 178.0, but the paintExtent is 360.0. By definition, a sliver can't paint more
I/flutter (25161): than the maximum that it can paint!
I/flutter (25161): The RenderSliver that returned the offending geometry was:
I/flutter (25161): RenderSliverGrid#ba222 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (25161): creator: SliverGrid ← MediaQuery ← SliverPadding ← Viewport ← _ScrollableScope ←
I/flutter (25161): IgnorePointer-[GlobalKey#bcd2a] ← Semantics ← Listener ← _GestureSemantics ←
I/flutter (25161): RawGestureDetector-[LabeledGlobalKey#e36d5] ←
I/flutter (25161): _ScrollSemantics-[GlobalKey#e2845] ← RepaintBoundary ← ⋯
I/flutter (25161): parentData: paintOffset=Offset(0.0, 0.0) (can use size)
I/flutter (25161): constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle,
I/flutter (25161): scrollOffset: 0.0, remainingPaintExtent: 596.7, crossAxisExtent: 360.0, crossAxisDirection:
I/flutter (25161): AxisDirection.right, viewportMainAxisExtent: 596.7, remainingCacheExtent: 846.7 cacheOrigin: 0.0 )
I/flutter (25161): geometry: SliverGeometry(scrollExtent: 178.0, paintExtent: 360.0, maxPaintExtent: 178.0,
I/flutter (25161): hasVisualOverflow: true, cacheExtent: 360.0)
I/flutter (25161): currently live children: 0 to 1
I/flutter (25161):
I/flutter (25161): When the exception was thrown, this was the stack:
I/flutter (25161): #0 SliverGeometry.debugAssertIsValid..verify (package:flutter/src/rendering/sliver.dart:674:9)
I/flutter (25161): #1 SliverGeometry.debugAssertIsValid. (package:flutter/src/rendering/sliver.dart:694:15)
I/flutter (25161): #2 SliverGeometry.debugAssertIsValid (package:flutter/src/rendering/sliver.dart:706:6)
I/flutter (25161): #3 RenderSliver.debugAssertDoesMeetConstraints (package:flutter/src/rendering/sliver.dart:1061:21)
I/flutter (25161): #4 RenderObject.layout. (package:flutter/src/rendering/object.dart:1636:19)
I/flutter (25161): #5 RenderObject.layout (package:flutter/src/rendering/object.dart:1636:67)
I/flutter (25161): #6 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182:11)
I/flutter (25161): #7 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (25161): #8 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:405:13)
I/flutter (25161): #9 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1316:12)
I/flutter (25161): #10 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1234:20)
I/flutter (25161): #11 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (25161): #12 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (25161): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (25161): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (25161): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (25161): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (25161): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (25161): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (25161): #22 _invoke (dart:ui/hooks.dart:156:10)
I/flutter (25161): #23 _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter (25161): (elided 3 frames from package dart:async)
I/flutter (25161):
I/flutter (25161): The following RenderObject was being processed when the exception was fired:
I/flutter (25161): RenderSliverGrid#ba222 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (25161): creator: SliverGrid ← MediaQuery ← SliverPadding ← Viewport ← _ScrollableScope ←
I/flutter (25161): IgnorePointer-[GlobalKey#bcd2a] ← Semantics ← Listener ← _GestureSemantics ←
I/flutter (25161): RawGestureDetector-[LabeledGlobalKey#e36d5] ←
I/flutter (25161): _ScrollSemantics-[GlobalKey#e2845] ← RepaintBoundary ← ⋯
I/flutter (25161): parentData: paintOffset=Offset(0.0, 0.0) (can use size)
I/flutter (25161): constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle,
I/flutter (25161): scrollOffset: 0.0, remainingPaintExtent: 596.7, crossAxisExtent: 360.0, crossAxisDirection:
I/flutter (25161): AxisDirection.right, viewportMainAxisExtent: 596.7, remainingCacheExtent: 846.7 cacheOrigin: 0.0 )
I/flutter (25161): geometry: SliverGeometry(scrollExtent: 178.0, paintExtent: 360.0, maxPaintExtent: 178.0,
I/flutter (25161): hasVisualOverflow: true, cacheExtent: 360.0)
I/flutter (25161): currently live children: 0 to 1
I/flutter (25161): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (25161): RenderIndexedSemantics#04bae NEEDS-PAINT
I/flutter (25161): RenderRepaintBoundary#af3ad NEEDS-PAINT
I/flutter (25161): RenderSemanticsGestureHandler#a7dbb NEEDS-PAINT
I/flutter (25161): RenderPointerListener#132a7 NEEDS-PAINT
I/flutter (25161): RenderSemanticsAnnotations#ef278 NEEDS-PAINT
I/flutter (25161): RenderIndexedSemantics#57f8f NEEDS-PAINT
I/flutter (25161): RenderRepaintBoundary#f31a0 NEEDS-PAINT
I/flutter (25161): RenderPadding#3867c NEEDS-PAINT
I/flutter (25161): RenderPositionedBox#bb1ec NEEDS-PAINT
I/flutter (25161): RenderFlex#48555 relayoutBoundary=up1 NEEDS-PAINT
I/flutter (25161): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (25161): App is in debug mode

[Question] Restore scrollposition

Hi,
is there any way to store and restore the scrollposition of the List?
I tried to use PageStorageKey but i cant figure out, what to use as a key to make it work.
I tried different things (like the pageIndex) but it messed up the behavior of the list..

Thanks again for your help :)

Support for retry all failed request

When I clicked on the refresh indicator on the error builder, it only retry the particular failed request. I suggest it should retry for all the failed request or at least add a flag to control that.

About the screenshot

Can you provide the ability to generate a long image of all the gridview content?
Including the invisible parts, I desperately need this functionality, but do not know how to implement

Add way to build separators.

Something similar to ListView.separated(...). Perhaps we can have something like PagewiseListView.separated(...)?

Give access to retry()

In order to build a custom RetryWidget, we need access to retry() method to retry the request

Scrolling Problem

Hi,
when scrolling up or down it seem that the loading are is not being blocked inside the screen.
Should n't be looking the scaffold on the next X loading items with the circular loader?

Search feature

Hi guys,
I am developing an app and I would like to integrate it with a search function.
Basically I am going to add to my appbar a new class that will extend searchDelegate and build all the necessary things for a "modal" search.

`
class ShowSearch extends SearchDelegate {

@OverRide
List buildActions(BuildContext context) {
// TODO: implement buildActions
return [IconButton(
icon: Icon(Icons.clear),
onPressed: (){
query = "";
}
)];
}

@OverRide
Widget buildLeading(BuildContext context) {
// TODO: implement buildLeading
return IconButton(icon: Icon(Icons.arrow_back), onPressed: (){
close(context, null);
});
}

@OverRide
Widget buildSuggestions(BuildContext context) {
// TODO: implement buildSuggestions
}

@OverRide
Widget buildResults(BuildContext context) {
// TODO: implement buildResults
int _totalCounter = 100;

return PagewiseGridView(
    pageSize: 10,
    totalCount: _totalCounter,
    crossAxisCount: 2,
    mainAxisSpacing: 10.0,
    crossAxisSpacing: 5.0,
    padding: EdgeInsets.all(5.0),
    itemBuilder: _itemBuilder,
    pageFuture: BackendService().getSearchItems,
);

}
`

and this is getSearchItems

`
static Future getSearchModels(query, searchIndex) async {
searchIndex = await searchIndex+1;
var query = "flutter";

var mySearchRes = await http.get(Uri.encodeFull("https://www.mydomain.com/wp-json/myapp/v1/search/$query/$searchIndex"), headers: {"Accept": "application/json"});
var mySearchResBody = json.decode(mySearchRes.body);

List searchList = [];

for (var modelSearches in mySearchResBody["posts"]){
  searchList.add(modelSearches);
}
return searchList;

}
`

My problem is that it shows a red screen saying
type 'Future<List<dynamic>>' is not a subtype of type '(int) => Future<List<dynamic>>'
when I change the pageFuture to
pageFuture: BackendService().getSearchItems("flutter", 1),
where flutter is what I am searching and 1 is the page number that is retrieving 10 results at the time.

How can I fix this...

Can't provide controller. Assertion failed.

When trying to provide a controller as following

    return RefreshIndicator(
        key: _refreshIndicatorKey,
        onRefresh: _onRefresh,
        child: PagewiseListView(
          controller: _pagewiseLoadController,
          itemBuilder: (context, entry, index) {
            var post = entry;

            return OBPost(
              post,
              onPostDeleted: _onPostDeleted,
              key: Key(
                post.id.toString(),
              ),
            );
          },
        ));

An exception is thrown

Performing hot restart...
Syncing files to device Android SDK built for x86...
Restarted application in 2,099ms.
I/flutter (14795): Initialising universal links
I/flutter (14795): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (14795): The following assertion was thrown building OBTimelinePosts(dirty, state:
I/flutter (14795): OBTimelinePostsState#3b437):
I/flutter (14795): 'package:flutter_pagewise/flutter_pagewise.dart': Failed assertion: line 166 pos 16: '(controller ==
I/flutter (14795): null && pageSize != null && pageFuture != null) ||
I/flutter (14795):             (controller != null && pageSize == null && pageFuture == null)': is not true.
I/flutter (14795): 
I/flutter (14795): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (14795): more information in this error message to help you determine and fix the underlying cause.
I/flutter (14795): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (14795):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (14795): 
I/flutter (14795): When the exception was thrown, this was the stack:
I/flutter (14795): #2      new Pagewise (package:flutter_pagewise/flutter_pagewise.dart:166:16)
I/flutter (14795): #3      new PagewiseListView (package:flutter_pagewise/flutter_pagewise.dart:497:9)

The PagewiseListView has no pageSize nor pageFuture, while the controller does.

Looking for contributors

Hello all,

I am low on time, and I don't want to keep this project hanging. So, is anyone interested in helping maintain the project, implement new features, etc. ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.