I used Expandable in NestedScrollView and add ScrollOnExpand to fully display the widget that exceeds the screen.
The problem is that triggering ScrollOnExpand when the Widget exceeds the upper area of the screen will cause the screen to scroll to the top:
NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
expandedHeight: 200.0,
flexibleSpace: FlexibleSpaceBar(
title: Text('SliverAppBar'),
),
pinned: true,
),
];
},
body: CustomScrollView(
slivers: [
SliverList.builder(
itemCount: 20,
itemBuilder: (BuildContext context, int index) {
return Container(
key: ValueKey('test1 $index'),
margin: EdgeInsets.all(30),
color: Colors.grey,
child: ExpandableNotifier(
key: ValueKey('test2 $index'),
child: ScrollOnExpand(
key: ValueKey('test3 $index'),
child: Column(
key: ValueKey('test4 $index'),
children: [
ExpandableTheme (
data:ExpandableThemeData(
animationDuration: Duration(milliseconds: 1000),
),
child: ExpandablePanel(
key: ValueKey('test5 $index'),
header: Text('test $index'),
collapsed: Text('test collapsed $index'),
expanded: SizedBox(height:100,child: Text('test expanded $index')),
),
),
ExpandableButton(child: Text('button $index') ,)
],
),
),
),
);
},
),
],
),
)
I found a similar question in the author’s Github, but it didn’t work.