CustomscrollView scrolled to position top automatically, when i tap a textfield in sliver app bar
First add a ScrollController to your customScrollView. Then animate to the offset position you would like eg.
class _HomeScreenState extends State<HomeScreen> { ScrollController scrollController; @overridevoid initState() {super.initState();scrollController = new ScrollController();} @overrideWidget build(BuildContext context) {return CustomScrollView( controller = scrollController, slivers: <Widget>[ .... your wiidgets... ],);/* this method should be called on search bar textField tapped or when on whatever event */void toTop(){ scrollController.animateTo(0, duration: Duration(milliseconds: 500), curve: Curves.easeInOut);}
Hope this helps anyone else......