How to use a ternary with a ListView within a PageView

You just have to remove the [ and ] from the ternary condition.

The Expanded widget takes in a widget as the child property. But currently, you are passing a List by using [ & ]. Removing these square brackets will remove the error.

Expanded(
  child: rollRows == 1
    ? 
        Center(
          child: Text(
            'No shifts to display',
            style: TextStyle(fontSize: 18, color: kBodyText),
          ),
        )             
      
    :   
        ListView.builder(
          itemCount: rollRows.length,
          itemBuilder: (BuildContext context, int index) {
            return rosterViewCard(rollRows[index]);
          },
        ),
      
)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top