Skip to content

ListTile with tileColor behaves strange in sliver with animation #83124

@TatsuUkraine

Description

@TatsuUkraine

When ListTile with specified tileColor is used inside slivers, it behaves strange during an animation apply.

Steps to Reproduce

Use the following code example and tap on Toggle button to hide and then show the list tile.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatefulWidget {
  @override
  _MyWidgetState createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  bool _show = true;
  
  @override
  Widget build(BuildContext context) {
    
    return Scaffold(
      appBar: AppBar(title: Text('Tile example')),
      body: CustomScrollView(
        slivers: [
          SliverToBoxAdapter(
            child: AnimatedSwitcher(
              duration: Duration(milliseconds: 300),
              transitionBuilder: (Widget child, Animation<double> animation) =>
                SizeTransition(
                  sizeFactor: animation,
                  axisAlignment: 1,
                  child: child,
                ),
              child: _show ? ListTile(
                tileColor: Colors.yellow,
                title: Text('Titlte'),
              ) : SizedBox.shrink(),
            ),
          ),
          SliverToBoxAdapter(
            child: ElevatedButton(
              child: Text('toggle'),
              onPressed: () {
                setState(() {
                  _show = !_show;
                });
              },
            ),
          ),
        ],
      ),
      
    );
  }
}

Expected results: ListTile should remain color after it opened

Actual results: Color is missing

First noticed Flutter 2.2

Logs

[✓] Flutter (Channel stable, 2.2.0, on macOS 11.3 20E232 darwin-x64, locale ru-UA)
    • Flutter version 2.2.0 at /Users/tatsu/flutter
    • Framework revision b22742018b (7 days ago), 2021-05-14 19:12:57 -0700
    • Engine revision a9d88a4d18
    • Dart version 2.13.0

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions