Flutter Offstage and ListTile

Dr_Skele·2022년 9월 21일
0

Flutter

목록 보기
1/19

Reference :
https://api.flutter.dev/flutter/widgets/Offstage-class.html
https://api.flutter.dev/flutter/material/ListTile-class.html

Offstage and ListTile

One thing I've noticed using Offstage was that it hides most widgets but not certain widgets like ListTile, Ink, etc.

Offstage(
          offstage: true,
          child: ListTile(
            tileColor: Colors.green,
          ),
        )

You expect above code to hide the ListTile widget which is the child of Offstage widget, but, It doesn't. Likewise, Ink also can be seen whether offstage value is true or not.

The reason for this is InkWell which ListTile is made of. I don't know much about it, but what I've known from some experiments is ColoredBox and InkWell behaves differently when rendering.

Offstage(
          offstage: true,
          child: Material(
            child: ListTile( 
              tileColor: Colors.green,
            ),
          ),
        )

Anyways, What we need is way to make ListTile disappear when offstage value is set to true. Way to do this is wrapping ListTile with Material like the code above. This was the best way so far. It doesn't remove animation, and also works fine with Offstage.

profile
Tireless And Restless Debugging In Source : TARDIS

0개의 댓글