简体   繁体   English

子ListView在颤动中完成滚动后如何继续滚动bottomModelSheet?

[英]How to continious scroll bottomModelSheet after child ListView completes the scroll in flutter?

I have the showModalBottomSheet widget which I am calling when the user clicks on a button and it has listView as a child widget.我有一个showModalBottomSheet小部件,当用户点击一个按钮时我会调用它,它有listView作为子小部件。

with this, I am able to scroll through the bottom model sheet,有了这个,我可以滚动底部的模型表,

But how to continuously scroll the bottom model sheet down after the listview has completed scrolling down?但是如何在列表视图完成向下滚动后继续向下滚动底部模型表?

Currently, the bottom model sheet does not go down just the ListView indicates the completion of scroll.目前,底部模型表不会下降,只是ListView指示滚动完成。

在此处输入图片说明

instead of scroll complete feedback, I want to scroll down the BottomModelSheet when ListView done scrolling.而不是滚动完整的反馈,我想在ListView完成滚动时向下滚动BottomModelSheet Is there any way to achieve this with `showModalBottomSheet'?有什么办法可以用`showModalBottomSheet'来实现这一点吗?

  class _ExampleState extends State<Example> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: <Widget>[
            RaisedButton(
              child: Text('Press Me'),
              onPressed: () async => await showModalBottomSheet(
                  // isScrollControlled: true,
                  context: context,
                  builder: (ctx) => ListViewWidget()),
            ),
          ],
        ),
      ),
    );
  }
}

class ListViewWidget extends StatefulWidget {
  @override
  _ListViewWidgetState createState() => _ListViewWidgetState();
}

class _ListViewWidgetState extends State<ListViewWidget> {
  ScrollController _scrollController;
  ScrollPhysics _scrollPhysics;

  void _scrollListener() async {
    if (_scrollController.position.pixels ==
        _scrollController.position.minScrollExtent) {
      setState(() {
        _scrollPhysics = NeverScrollableScrollPhysics();
      });
    }
  }

  @override
  void initState() {
    _scrollController = ScrollController()..addListener(_scrollListener);
    _scrollPhysics = AlwaysScrollableScrollPhysics();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      shrinkWrap: true,
      itemCount: kStates.length,
      controller: _scrollController,
      physics: _scrollPhysics,
      itemBuilder: (_, index) => GestureDetector(
        child: Text(
          kStates[index],
          style: TextStyle(
            color: Colors.black,
          ),
        ),
      ),
    );
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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