Small details that build taste in Flutter.

curated by Kamran BekirovKamran Bekirov

Tapping statusbar must scroll the page to top on iOS

Tapping the statusbar to scroll page to the top is native to iOS, and most users expect it.

See example from BunPod:

Flutter handles that automatically when you use Scaffold and CupertinoPageScaffold.

So... end of the tip?

No. There's a catch:

If you have a customScrollController, you must wrap the Scaffold (or CupertinoPageScaffold) with a PrimaryScrollController and provide that controller down the widget tree:

PrimaryScrollController(
    controller: _scrollController, // pass here
    child: Scaffold(
        appBar: const MyAppBar(),
        body: NestedScrollView(
            controller: _scrollController, // also pass to the scrollable
            headerSliverBuilder: (context, innerScrolled) {
                return [
                    ...
                ];
            },
            body: ...
        ),
    ),
);

This is basically saying to the Scaffold: "Hey! Thanks for helping. Uhm, I uh, brought my own ScrollController this time, and providing it above you so you can use when you need too. Thanks for your understanding! ☺️"

Thanks Scaffold for always taking care of that 🩵.

Kamran Bekirov
Kamran Bekirov

Want this level of care in your Flutter apps?

Work With Me