我有一个可滚动的AnimatedList,我希望每当将新项目添加到列表末尾时,它都会滚动到末尾。
我尝试应用此代码表单,ListView但它不起作用。
import 'package:flutter/material.dart';
class TestPage extends StatefulWidget {
@override
_TestPageState createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
List<String> list = ["a", "a", "a", "a", "a", "a", "a"];
final ScrollController _listScrollController = new ScrollController();
final GlobalKey<AnimatedListState> _listKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: AnimatedList(
key: _listKey,
controller: _listScrollController,
initialItemCount: list.length,
itemBuilder: (BuildContext context, int index, Animation animation) {
return FadeTransition(
opacity: animation,
child: Container(
width: itemSize,
height: itemSize, …Run Code Online (Sandbox Code Playgroud)