Giter Site home page Giter Site logo

themisir / flutter-listutils Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 9.0 201 KB

๐Ÿ”Œ Adapter support for Flutter ListView

Home Page: https://pub.dev/packages/listview_utils

License: MIT License

Dart 92.28% Kotlin 0.57% Swift 1.85% Objective-C 0.17% HTML 5.13%
flutter flutter-package pubdev

flutter-listutils's Introduction

Hello there,

General Kenobi. I write software. I like Rustlang and Golang, but have to write C# instead. I like writing systems software, low level stuff, playing with bits and bytes, sometimes exploring deep into CPU level and when bored I may prefer to write some HTML+CSS as well.

  • I write blogs and essays, or sometimes post some photos on https://themisir.com
  • I maintain my own little infrastructure for running self-hosted and some self-made tools
  • I work at bp, mostly doing system level software engineering
  • I hate Microsoft due to their non consumer friendly behavior (though I may eventually work there)
  • I will write my own game engine and A Game! from scratch

That's a darn long list to describe me, it's not an authentic one because it's a public one, but I tried to be as realistic as possible while being employer friendly (except MSFT).

Email me if you wanna talk (:

flutter-listutils's People

Contributors

g123k avatar ludwiktrammer avatar mrcsabatoth avatar roduankd avatar themisir avatar waleedalrashed 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

Watchers

 avatar

flutter-listutils's Issues

Controller is missing

Unlike the classical ListView CustomListView doesn't have controller field. So adding CustomListView to the project we can't use a lot of features that controllers provide us (jumpTo, initialScrollOffset etc.).

It would be nice to add a controller to CustomListView.

Add support for GridView

This is a good package for pagination, header & footer builder, custom network request adapter, and so on.
It would be better if you add GridView support to this package.

Thanks

Support SliverAppBar as header

I would like to use the SliverAppBar as the header but right now this is not possible because of the explicit SliverToBoxAdapter being used with the header.

https://github.com/TheMisir/flutter-listutils/blob/master/lib/src/custom_list_view.dart#L367

Ideally we should either detect if the header is an instance of theSliverAppBar or maybe more broadly let the user tell us if the header is a sliver (this concept could / should probably be extended to the footer as well if we decide to go this way).

@themisir what do you think ?

List shows loading and empty widget's at the same time

Given the following code:

return Scaffold(
  drawer: AppDrawer(activeRoute: activeRoute),
  appBar: AppBar(title: title),
  body: CustomListView(
    empty: Text("Empty"),
    pageSize: 12,
    loadingBuilder: (BuildContext context) => Center(child: CircularProgressIndicator()),
    adapter: ListAdapter(fetchItems: (int offset, int limit) async {
      var items = await fetchItems(offset,limit);
      return ListItems(items.data, reachedToEnd: items.to == items.total);
    }),
    itemBuilder: (BuildContext context, int idx, dynamic item) => MyListItem(item),
  ),
);

Both the word "empty" and the CircularProgressIndicator are visible to the user.
Please, correct me if I'm wrong, but this doesn't seem like the intended behaviour?

image

Cannot stop StaticListAdapter from loading more and more copies of the page

Describe the bug
I'm trying to create a list with StaticListAdapter which truly just displays a page and doesn't grow. Right now however regardless of disablePagination true or false swipe down gestures keep loading more and more copies of the set page.

To Reproduce
Steps to reproduce the behavior:

  1. Take the example code
  2. Modify the initialOffset to 0
  3. Add this adapter: StaticListAdapter(data: ["Lorem", "ipsum", "dolor", "sit", "amet"]),
  4. Modify the itembuilder to accommodate the simple String list: title: Text(item),
  5. Try repeatedly issue swipe down gestures. With each gesture a new set of ["Lorem", "ipsum", "dolor", "sit", "amet"] is added to the list

Expected behavior
There has to be a scenario where no more copies are loaded.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel beta, 1.22.0-12.1.pre, on Linux, locale en_US.UTF-8)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 4.0)
[โœ“] VS Code (version 1.49.2)
[โœ“] Connected device (3 available)

โ€ข No issues found!

Additional context
I'll craft a PR.

The list view renders `widget.empty` before it's initial load

Describe the bug
The list view renders widget.empty before it's initial load

To Reproduce
Steps to reproduce the behaviour:

  1. Create a listview that uses an adapter that returns a future
  2. Pass an empty widget that is visible
  3. See empty widget before initial load

Expected behaviour
The user should not see the empty widget before the list has loaded

Flutter doctor

[โˆš] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.19041.388], locale en-GB)
    โ€ข Flutter version 1.17.5 at C:\tools\flutter
    โ€ข Framework revision 8af6b2f038 (4 weeks ago), 2020-06-30 12:53:55 -0700
    โ€ข Engine revision ee76268252
    โ€ข Dart version 2.8.4


[โˆš] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    โ€ข Android SDK at C:\tools\android\sdk
    โ€ข Platform android-29, build-tools 29.0.3
    โ€ข ANDROID_HOME = C:\tools\android\sdk
    โ€ข Java binary at: C:\Program Files\OpenJDK\openjdk-8u252-b09\bin\java
    โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_252-b09)
    โ€ข All Android licenses accepted.

Additional context
I believe this is being caused by _CLVStatus being initialised as _CLVStatus.idle as opposed to _CLVStatus.loading

Migrate to sound null safety

Describe the solution you'd like
Migrate to sound null safety. Flutter 2.0 supports null safety. Would be great if this package provides this feature as well.

Is there any continuation plugin derived from this project?

Is your feature request related to a problem? Please describe.
I'm relying on this plugin for my DB connected list views and now with Dart 3 it's holding dependencies back, such as http. I understand that in some cases someone might fiddle with their own state management (Provider, RiverPod2, BLoC, etc.), however when I just has a Floor object list stored in the DB and simply want to display that in a listview, if I don't use this plugin then I'd repeat paging and all shenanigans 7x? I think that would be bad. I might be wrong.

Describe the solution you'd like
Finding a plugin which is the continuation of this plugin, for example listview_utils_plus.

Describe alternatives you've considered
Forking the project and upgrading it by myself.

Additional context
Thanks for you work in the past.

Switching from 0.1.x to 0.2.y breaks the code without adapter

Describe the bug
I was using version 0.1.5 of the package with the parameters below and it worked flawlessly. Now, I tried to upgrade the package to 0.2.6+2 and I get an error regarding missing data, although the model.data is still there in the same way.

To Reproduce
Steps to reproduce the behavior:

  1. Use newest version of the package
  2. Use the following code for the CustomListView:
Expanded(
 child: CustomListView(
  onRefresh: () {
    model.updateData();
    return;
    },
 loadingBuilder: CustomListLoading.defaultBuilder,
 itemCount: model.data.length ?? 0,
 itemBuilder: (context, index, item) {
  final item = model.data[index];
  return Text(item.amount.toString());
  },
 ),
)
  1. Get error: RangeError (index): Invalid value: Valid value range is empty: 0

Expected behavior
The list should load the data from model.data since in the older version it works.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[โˆš] Flutter (Channel stable, 1.22.0, on Microsoft Windows [Version 10.0.19041.508], locale de-CH)
[โˆš] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc2)
[โˆš] Android Studio (version 3.6)
[โˆš] VS Code, 64-bit edition (version 1.49.3)
[โˆš] Connected device (1 available)

โ€ข No issues found!

When separator is configured the last item is not shown

Describe the bug
When there's a separator configured the last item is not shown. The logic has a bug. The separator is an individual list item and to accommodate it the number of items is artificially doubled (minus 1 to account for the lack of trailing separator).

To Reproduce
Steps to reproduce the behavior:

  1. Take the example code
  2. Modify the initialOffset to 0
  3. Add this adapter: StaticListAdapter(data: ["Lorem", "ipsum", "dolor", "sit", "amet"]),
  4. Modify the itembuilder to accommodate the simple String list: title: Text(item),
  5. The last item amet won't be shown in the list. Subsequently if the list is just one item (which was my case with a Floor SQLite adapter, and I was searching for wring places why it didn't display) then nothing is displayed.

Expected behavior
All of the items are displayed including the last one (at least if they can fit to screen).

Screenshots
Screenshot_20200920-155619

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[โœ“] Flutter (Channel beta, 1.21.0-9.2.pre, on Linux, locale en_US.UTF-8)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 4.0)
[โœ“] VS Code (version 1.49.1)
[โœ“] Connected device (2 available)

โ€ข No issues found!

Additional context
I haven't had time to find the exact location of the bug. It's most probably SliverChildDelegate _buildDelegate(). The workaround is to not use a separator.

CustomListView breaks when switching from 0.1.5 to 0.2.6+2 in combination without adapter

Describe the bug
I was using version 0.1.5 of the package with the parameters below and it worked flawlessly. Now, I tried to upgrade the package to 0.2.6+2 and I get an error regarding missing data, although the model.data is still there in the same way.

To Reproduce
Steps to reproduce the behavior:

  1. Use newest version of the package
  2. Use the following code for the CustomListView:
Expanded(
 child: CustomListView(
  onRefresh: () {
    model.updateData();
    return;
    },
 loadingBuilder: CustomListLoading.defaultBuilder,
 itemCount: model.data.length ?? 0,
 itemBuilder: (context, index, item) {
  final item = model.data[index];
  return Text(item.amount.toString());
  },
 ),
)
  1. Get error: RangeError (index): Invalid value: Valid value range is empty: 0

Expected behavior
The list should load the data from model.data since in the older version it works.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[โˆš] Flutter (Channel stable, 1.22.0, on Microsoft Windows [Version 10.0.19041.508], locale de-CH)
[โˆš] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc2)
[โˆš] Android Studio (version 3.6)
[โˆš] VS Code, 64-bit edition (version 1.49.3)
[โˆš] Connected device (1 available)

โ€ข No issues found!

onRefresh behaviour without adapter does not load new data

When I use the onRefresh method it does not rerun the itemCount function in order to check if new data has been loaded.

In the docs it says:
onRefresh โ†’ AsyncCallback
Called when refresh is triggered, default behaviour is to set offset to zero and re-load entries from adapter
final

Is it possible that the itemCount is not updated when you don't use an adapter?

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.