CupertinoSliverRefreshControl blinks sometimes when Container is returned from builder

0

In my app I need to provide a pull-to-refresh on one of the screens. I've chosen CupertinoSliverRefreshControl. App's primary color is red, so the navbar and searchbar are colored with it. And also refresh control needs to be colored with red. But when I return Container with color from CupertinoSliverRefreshControl's method, the whole control kind-of blinks with white stripe, when reaches the zero position after onRefresh completes.

Widget structure is the following:

import 'package:flutter/cupertino.dart';

void main() {
  runApp(App());
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      home: CupertinoPageScaffold(
        child: CustomScrollView(
          slivers: <Widget>[
            /// navbar
            CupertinoSliverNavigationBar(
              backgroundColor: Color(0xffe30613),
              largeTitle: Text(
                'App',
                style: TextStyle(
                  color: Color(0xffffffff),
                ),
              ),
            ),

            /// pull to refresh control
            CupertinoSliverRefreshControl(
              onRefresh: () => Future.delayed(Duration(milliseconds: 1000)),
              builder: (_, __, ___, ____, _____) {
                return Container(
                  color: Color(0xffe30613),
                  child: Center(
                    child: const CupertinoActivityIndicator(
                      radius: 12.0,
                    ),
                  ),
                );
              },
            ),

            /// searchbar
            SliverToBoxAdapter(
              child: Container(
                height: 56.0,
                padding: const EdgeInsets.symmetric(
                  horizontal: 8.0,
                  vertical: 10.0,
                ),
                color: Color(0xffe30613),
                child: Container(
                  color: Color(0xffffffff),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Here's the demonstration of the problem:

demonstration

UPDATE:

Referencing to the issue I've created in flutter's repo, the problem is in CupertinoSliverRefreshControl itself. In fact, it is not a problem, but an expected behavior. When Control's refreshState reaches inactive, build method returns an empty Container, which is, by default, 10% of height of control. This exact Container is visible on gif above above.

I've created Pull Request, that adds param to control this Container color, now waiting for it to be merged.

dart
flutter
pull-to-refresh
asked on Stack Overflow Jan 22, 2019 by vanelizarov • edited Jan 23, 2019 by vanelizarov

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0