Manish Kumar
Manish Kumar

Reputation: 3

Problem rendering widgets above expanded listview in a column

I'm trying to render a Column (inside CupertinoPageScaffold) where the column has (in the children) widgets before and after an expanded listview. The widgets which are after the listview are rendered but the ones before the listview are not rendered. Link to image with rendered screen

class TestWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Container(
          constraints: BoxConstraints(
            minHeight: 50.0,
          ),
          child: Center(
            child: Text(
              'Top label',
              style: TextStyle(
                  fontSize: 22.0,
                  fontWeight: FontWeight.bold,
                  color: Colors.teal),
            ),
          ),
        ),
        Expanded(
          child: ListView.separated(
            itemCount: 20,
            separatorBuilder: (context, index) {
              return Divider();
            },
            itemBuilder: (context, index) {
              return Material(
                child: ListTile(
                  leading: CircleAvatar(),
                  title: Text('Test title'),
                ),
              );
            },
          ),
        ),
        Container(
          constraints: BoxConstraints(
            minHeight: 50.0,
          ),
          child: Center(
            child: Text(
              'Bottom label',
              style: TextStyle(
                  fontSize: 22.0,
                  fontWeight: FontWeight.bold,
                  color: Colors.teal),
            ),
          ),
        ),
      ],
    );
  }
}

Upvotes: 0

Views: 48

Answers (1)

diegoveloper
diegoveloper

Reputation: 103351

Just add your TestWidget inside SafeArea .


SafeArea(
 child: TestWidget()
);


Upvotes: 1

Related Questions