Giter Site home page Giter Site logo

chimon2000 / async_loader Goto Github PK

View Code? Open in Web Editor NEW
100.0 100.0 15.0 232 KB

A flutter plugin for loading content asynchronously.

Home Page: https://pub.dartlang.org/packages/async_loader

License: ISC License

Java 6.42% Objective-C 13.04% Dart 75.83% Shell 4.71%
dart flutter

async_loader's Introduction

Ryan Edge #StayWoke

Hi there ๐Ÿ‘‹! I am a Google Developer Expert in Flutter and who is passionate about civic hacking and front-end development on mobile, desktop, and web platforms. I blog somewhat regularly on hashnode. I live in Charlotte, NC but I'm a Louisiana native โšœ๏ธ. I'm a nerd jock ๐Ÿค“๐Ÿƒ, an anime enthusiast, an epicure, and an advocate for equality โœŠ๐Ÿพ ๐Ÿฆ„.

  • ๐Ÿ’ฌ Ask me about Flutter, Web Components, Anime, or Food
  • ๐Ÿ“ซ How to reach me: DM me @chimon1984 or email me at [email protected]
  • ๐Ÿ˜„ Pronouns: he/him
  • โšก Fun fact: I am a movie buff.

I offer freelance services including full-stack & mobile development and project management.

async_loader's People

Contributors

bcko avatar chimon2000 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

async_loader's Issues

Null-Safety

Any plans to migrate this package to null-safety soon?

Missing option to track reload status

The current implementation allows for reload using

  • reloadState() { _initState(); }
  • initState returns a Future and hence can be used to get notified when operation has finished.
  • reloadState however is not 'async' and does not return anything.

Problem

  • When using something like a RefreshIndicator you need a callback when the refresh process has finished so that the progress indicator can be removed.

Add ability to timeout futures

Is your feature request related to a problem? Please describe.

Currently, timeout and its errors must be wired up to the widget imperatively.

Describe the solution you'd like

Add timeout property

  • Cancels request after timeout
  • Executes error builder with isTimeout = true

Describe alternatives you've considered

N/A

Additional context

https://github.com/jxom/react-loads#timeout

Change 'render' to 'builder'

Is your feature request related to a problem? Please describe.
This is to standardize closely to Flutter widgets that use a builder function rather than a render function.

Describe the solution you'd like

  1. renderLoad becomes buildLoad
  2. renderError becomes buildError
  3. renderSuccess becomes buildSuccess

Describe alternatives you've considered
N/A

Additional context
Add any other context or screenshots about the feature request here.

Invert control of loading

Is your feature request related to a problem? Please describe.

Currently, the future is executed soon as the widget is rendered. Should allow for more fine grained control of loading.

Describe the solution you'd like

Add a loadOnMount property

  • Triggers whether or not the future is executed on default
  • Default to true

Add a load function to builder props.

  • Triggers load / reload future when executed

Describe alternatives you've considered

N/A

Additional context

https://github.com/jxom/react-loads#loadonmount

can we use this package for post request..

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

setState() called after dispose()

Hi there,

Let me explain my project:
I'm trying to develop an "Master-Detail" app using async_loader lib. The app consumes Github api listing some repositories. After that, if a user click on an list item he is sent to detail screen that consumes github api again to show the pull requests of that repository.

When i click to see the detail screen, I got that message of error:

setState() called after dispose(): AsyncLoaderState#dbc13(lifecycle state: defunct, not mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
breaking at exception: FlutterError

Here is my project in case you want to run and see what is happening:
GithubFlutter

Add builder function

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
To enable more robust use cases, the builder function will act as a fallback when the success / error / loading functions do not exist.

Describe alternatives you've considered
N/A

Additional context
N/A

Reloading like crazy in deeper navigation stack

First thank you for your nice library, which saved me a lot of time writing boilerplate codes. But I just stumbled a weird issue.

Here's my code:
https://github.com/tamcy/asyncloadertest/blob/master/lib/main.dart

It is very similar to the example of this library with two changes:

  • it shows a bottom sheet when an action button is tapped.
  • there is another button which brings users to another page (I am reusing the same class in this demo).

And here's a video of what happens:
https://github.com/tamcy/asyncloadertest/blob/master/demo.gif

As you see, the code is working perfectly in the first (home) page. But when navigated to the second page or deeper,

  • the async loader seems to init itself twice from the look of the progress indicator, before actually showing the content. This already indicates something isn't quite right.
  • whenever a dialog (bottom sheet in this example) is shown, the async loader reloads itself, which is obviously not right.

Things become normal again when GlobalKey is not assigned to async loader, but then there is no way to access the current state (which I need to).

I am new to Flutter, so I'm not sure if I am doing things incorrectly. My apologize if it is the problem of my side. Thanks in advance.

Change initState property to fn

Is your feature request related to a problem? Please describe.
N/A

Describe the solution you'd like
Init state has a very specific meaning. The future promise should be generic.

Describe alternatives you've considered
An alternative would be changing initState to future which copies FutureBuilder

Additional context
Relates to #16

Add more examples

Is your feature request related to a problem? Please describe.
Currently, developers can only see one example from running example app.

Describe the solution you'd like
Add paging to support multiple examples

Describe alternatives you've considered
N/A

Additional context
N/A

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.