import 'package:flutter/material.dart';
需要引入....
void main() {
runApp(MaterialApp(
theme: ThemeData.light(),
home: Builder(
builder: (BuildContext context) => Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: const Text("Not nested - working"),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => CustomWidget(nested: false),
));
},
),
RaisedButton(
child: const Text("Nested - not working"),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => CustomWidget(nested: true),
));
},
),
],
),
),
));
}
class CustomWidget extends StatelessWidget {
final
SliverList和CustomScrollView滑动到指定item
最新推荐文章于 2024-04-16 10:08:45 发布
本文介绍如何在Flutter中利用ScrollToIndex库,配合SliverList和CustomScrollView,实现滚动到指定的列表项。通过导入'package:scroll_to_index/scroll_to_index.dart',可以方便地在应用中添加这一功能。
摘要由CSDN通过智能技术生成