1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter: unexpected space at the top of ListView

Discussão em 'Mobile' iniciado por Stack, Novembro 6, 2024 às 00:52.

  1. Stack

    Stack Membro Participativo

    I have the following source code:

    @override
    Widget build(BuildContext context) {
    return Scaffold(
    body: CustomScrollView(
    controller: scrollController,
    slivers: <Widget>[
    SliverList(
    delegate: SliverChildBuilderDelegate(
    (context, cardIndex) {
    return Container(
    color: Colors.white,
    child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: <Widget>[
    Text(
    'Main Course',
    style: kRestaurantMenuTypeStyle,
    ),
    ListView.builder(
    itemCount: menuCards[cardIndex].menuItems.length,
    shrinkWrap: true,
    physics: NeverScrollableScrollPhysics(),
    scrollDirection: Axis.vertical,
    itemBuilder: (context, itemIndex) {
    return RestaurantMenuItem(
    menuItem: menuCards[cardIndex].menuItems[itemIndex],
    );
    },
    ),
    ],
    ),
    );
    },
    childCount: menuCards.length,
    ),
    ),
    ],
    ),
    );
    }


    Unfortunately, the ListView.builder() creates this extra space on top automatically. This is shown in the image below. That is the big white space between the 'Main Course' and 'Pancit Malabon' texts.

    [​IMG]

    I don't understand why ListView does that. How do I remove the space?

    Continue reading...

Compartilhe esta Página