Skip to content

Flickering when child contains FutureBuilder #34

@eriknstevenson

Description

@eriknstevenson

Hi,

First of all, thanks for creating this widget!

I've run into a small issue when using a Slidable widget that has a child containing a FutureBuilder widget, and I hope this an appropriate place to ask. Here is the code (slightly shortened) in question:

return Slidable(
      delegate: SlidableScrollDelegate(),
      actionExtentRatio: 0.25,
      secondaryActions: <Widget>[
        IconSlideAction(
          caption: 'Delete',
          color: Colors.red,
          icon: Icons.delete,
          onTap: () => removeLocation(location),
        ),
      ],
      child: ListTile(
        onTap: () {
          Navigator.pushNamed(context, Routes.closeUp);
        },
        leading: FutureBuilder<WeatherData>(
            future: location.weatherData,
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                return SizedBox(
                  width: 64.0,
                  height: 64.0,
                  child: ClipRRect(
                    borderRadius: BorderRadius.circular(64.0),
                    child: Image(
                      image: NetworkImage(snapshot.data.iconUrl),
                    ),
                  ),
                );
              }
              return CircularProgressIndicator();
            }),
      ),
    );

Now, this works fine however when the screen is redrawn (after a tap anywhere on the screen, for example), there is a slight flicker caused by (I think) the FutureBuilder going back to the ConnectionState.waiting status.

The FutureBuilder docs state the following which I think could be related:

A side-effect of this is that providing a new but already-completed future to a FutureBuilder will result in a single frame in the ConnectionState.waiting state. This is because there is no way to synchronously determine that a Future has already completed.

The futures I'm passing into the FutureBuilder are not being changed on my end (When I move the ListTile widget outside of the Slidable widget, the flicker goes away), but I was wondering if perhaps there might be something going on under the hood in Slidable that is causing this state to be affected.

If you have any ideas/suggestions as to what might be going on, or ways to avoid the flickering, it would be much appreciated.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions