It’s an useful behavior on the mobile app that when we scroll to the top of a vertical scroll view, and overscroll, a refresh indicator will drop down, then the new data updates after we release the control. Flutter provides a handy widget called
RefreshIndicator for this purpose.
As the official documentation says,
RefreshIndicator is a widget that supports the Material “swipe to refresh” idiom. Today, we’re going to learn how to implement it in our ScrollView.
Let’s try to display…
Hello guys, today I’m going to introduce another fantastic animation. When users tap the FAB(FloatingActionButton), we navigate them from page A to page B with an animation. Not like traditional fade-in/fade-out or slide-in/slide-out one. It provides a more interesting and intuitive behavior that lets users know there is a transition between two pages via tapping the FAB button. Okay, let’s get started~
MaterialPageRoutewith a custom fade-in/fade-out
Today we’re going to talk about how to
Slivers. Let’s say we want to display a list view or grid view on the screen, we can easily take advantage of ListView or GridView. But what if we want to show them both on the same page and scroll the screen as one page?
Slivers comes to save our lives!
A sliver is a portion of a scrollable area. You can use slivers to achieve custom scrolling effects.
Like the official document says, a Sliver is one of the portions…
Today I’m going to have a quick sharing for
FutureBuilder. Before we get started, I recommend you watch the video from Google.
We all know that Flutter provides
await keywords to let us handle the asynchronous tasks.
Basically, we’ll implement it like this:
fetchData() will wait for 1 second and return the value.
Step2() waits for it and then do the following tasks. The output will be like:
I/flutter (13420): Step 1, fetch data
I/flutter (13420): Step 2, hasData: true
This works because we add
step2(). Let’s try another case:
How to choose which Flutter animation is right for you?
Adding some animations to the app makes it more smooth, and improves the user experience. However, it sometimes confuses us that which approach should we take to achieve the animation. Today, we’re going to figure out the right way for us. In this post, you’ll see a series of questions that will help you determine what kind of solution should be used.
Basically, this post refers to this video from the Flutter team. Before we get started, I strongly recommend you to watch this amazing video.
I am writing the Flutter app recently. Sometimes we need to provide values from parent widget to child widget, and the official solution is to use
InheritedWidget. If we define the parent widget as an
InheritedWidget, the child widgets under it could obtain the nearest instance of a particular type of inherited widget from a build context by using BuildContext.dependOnInheritedWidgetOfExactType.
Although the solution above sounds nearly perfect, it takes us lots of time to write boilerplate code. In order to make it better, the
Provider, an incredible library, comes to save us.
We all know unit tests are important and necessary, and we also know we don’t really like to write it 😝. There are plenty of reasons that prevent us from writing good unit tests. The most likely situation I refuse to write it is that it often costs me double to triple time than to develop the main feature. After developing Android apps for 5~6 years, I found the main reasons resulting in that could be classified into two reasons:
As we’ve learned in the Kotlin Coroutines in Android — Basics,
Deferred transfers a single value between coroutines.
Channel could be considered to provide a stream of values between coroutines.
Before we start, I strongly recommend you watch the introduction of Coroutines Suspending Functions in Google I/O`19.
They use great images and animations that could help you to know how the Suspending Function works.
In the previous post, we learn about the basic concepts of Kotlin Coroutines.
Please read it if you still have no idea what is Kotlin Coroutines.
I only explained that
Suspending Functions allow us to suspend and wait until the function resumes. We didn’t go deeper since there is much to say for it and it worth another post…
An Android/Flutter engineer at Line Corporation.