简体   繁体   中英

How to stop ListView from scrolling automatically in Flutter?

Very trivial problem. Super simple code.

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: [
        Container(color: Colors.red, height: 1000),
        Container(color: Colors.blue, height: 1000),
      ],
    );
  }
}

It keeps snapping to the item instead of scrolling organically; any ideas?

在此处输入图像描述

There seems to be a scrollbug bug with Flutter + iOS Simulator 14.4.

Logged a bug with Flutter here:

https://github.com/flutter/flutter/issues/79641

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM