如何滚动到列表视图中的特殊小部件?例如,如果我按下特定按钮,我想自动滚动到ListView中的某个Container.
ListView(children: <Widget>[
Container(...),
Container(...), #scroll for example to this container
Container(...)
]);
Run Code Online (Sandbox Code Playgroud) 我有一个构建使用屏幕MaterialApp,DefaultTabController,Scaffold和TabBarView。
在这个屏幕中,我有正文内容,它使用StreamBuilder. 我得到精确的 100 个元素(“有限列表”)使用ListView.
我的问题是,ListView.builder当这个屏幕打开时,我们如何跳转到某个索引?
我的主屏幕:
...
ScrollController controller = ScrollController();
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner : false,
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
backgroundColor: Pigment.fromString(UIData.primaryColor),
elevation: 0,
centerTitle: true,
title: Text(translations.text("quran").toUpperCase()),
bottom: TabBar(
tabs: [
Text("Tab1"),
Text("Tab2"),
Text("Tab3")
],
),
leading: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: InkWell(
child: SizedBox(child: Image.asset("assets/images/home.png"), height: 10, width: 1,),
onTap: () => …Run Code Online (Sandbox Code Playgroud)