Flutter ListView不滚动(我觉得我已经尝试了互联网上的所有解决方案)

Sto*_* D. 3 mobile listview dart flutter

如果我拖动并按住手指,我可以看到屏幕截止线下方的一些项目,但一旦我松开手指,它就会弹回顶部。我尝试使用 SingleChildScrollView 位置,尝试设置 Primary = true,以及其他一些没有帮助的东西。我对扑动相当陌生,所以任何帮助将不胜感激!如果需要更多信息,请告诉我。

这是我的代码:

import 'package:flutter/material.dart';
import 'package:drink_specials/models/restaurant.dart';
import 'package:drink_specials/screens/home/restaurant_list.dart';

class RestaurantNameTextStyle {
  static TextStyle display5(BuildContext context) {
    return Theme.of(context).textTheme.headline2.copyWith(color: Colors.white);
  }
}

class RestaurantTypeTextStyle {
  static TextStyle display5(BuildContext context) {
    return Theme.of(context).textTheme.headline6.copyWith(color: Colors.white);
  }
}


class RestaurantDetail extends StatelessWidget {

  final Restaurant restaurant;
  RestaurantDetail({Key key, @required this.restaurant}) : super(key: key);

  @override
  Widget build(BuildContext context) {

    final topContentText = Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        SizedBox(height: 100.0),
        Text(
          restaurant.name,
          style: RestaurantNameTextStyle.display5(context),
        ),
        SizedBox(height: 10.0),
        Expanded(
            flex: 6,
            child: Padding(
                padding: EdgeInsets.only(left: 10.0),
                child: Text(
                  restaurant.restaurant_type,
                  style: RestaurantTypeTextStyle.display5(context),
                ))),
      ],
    );

    final topContent = Stack(
      children: <Widget>[
        Container(
            padding: EdgeInsets.only(left: 10.0),
            height: MediaQuery.of(context).size.height * 0.5,
            decoration: new BoxDecoration(
              image: new DecorationImage(
                image: NetworkImage(restaurant.photo),
                fit: BoxFit.cover,
              ),
            )),
        Container(
          height: MediaQuery.of(context).size.height * 0.5,
          padding: EdgeInsets.all(40.0),
          width: MediaQuery.of(context).size.width,
          decoration: BoxDecoration(color: Color.fromRGBO(58, 66, 86, .9)),
          child: Center(
            child: topContentText,
          ),
        ),
        Positioned(
          left: 8.0,
          top: 60.0,
          child: InkWell(
            onTap: () {
              Navigator.pop(context);
            },
            child: Icon(Icons.arrow_back, color: Colors.white),
          ),
        )
      ],
    );


    final bottomContent = Container(
      width: MediaQuery.of(context).size.width,
      padding: EdgeInsets.all(8.0),
      child: Center(
        child: ListView.builder(
          scrollDirection: Axis.vertical,
          physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
          itemCount: restaurant.specials.length,
          itemBuilder: (context, index) {
            final item = restaurant.specials[index];
            return Card(
              elevation: 8.0,
              margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
              child: Container(
                decoration: BoxDecoration(color: Color.fromRGBO(58, 66, 86, 1.0)),
                child: ListTile(
                  contentPadding: EdgeInsets.symmetric(horizontal:20, vertical:10),
                  title: Text(item, style: TextStyle(color: Colors.white)),
            )
                ),
            );
          }
        ),
      ),
    );

    return Scaffold(
      body: Column(
        children: <Widget>[
          topContent,
          Expanded(
            child: bottomContent,
          ),
        ],
      ),
    );
  }
}

Run Code Online (Sandbox Code Playgroud)

Ehs*_*ari 5

ListViewa 里面有一个SingleChildScrollView,两者都是可滚动的。应禁用在其中之一上滚动。