Reputation: 1052
I have 2 ListViews
the first one is one top of the page and shows stories so it's horizontal
and the second one is Showing Posts so it's vertical
.
What I want is that when I scroll
my posts I want the storys to disappear right now they are stuck on top of the page.
Explanation Video this
@override
Widget build(context) {
return Scaffold(
body: SafeArea(
child: Column(
children: [
Container(
padding: EdgeInsets.only(left: 15),
height: 90,
width: double.infinity,
child: StreamBuilder(
stream: masterListStart().asStream(),
builder: (context, snapshot) {
return (ConnectionState.done == snapshot.connectionState)
//First Listview
? ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: storysList.length,
itemBuilder: (context, index) {
//
StoryItems data = storysList[index];
//
return StoryItems(
data: data,
);
},
)
: CircularProgressIndicator();
}
},
),
);
//Second ListView
Expanded(
child: RefreshIndicator(
child: ListView(
children: posts,
),
key: refreshkey,
onRefresh: () => refreshlist(),
);
),
],
),
),
);
}
Upvotes: 1
Views: 2112
Reputation: 66
You can use CustomScrollView for it like this.
CustomScrollView(
slivers : [
SliverToBoxAdapter(child : Container(height : listHeight,
child ListView(),),),
SliverList(delegate: SliverChildBuilderDelegate((context,index){
return Your Item;
},
childCount: data.length
),]
Upvotes: 1
Reputation: 1
Use singlchildscrollview
as a parent widget instead of a column see the example
body: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Headline',
style: TextStyle(fontSize: 18),
),
SizedBox(
height: 200.0,
child: ListView.builder(
physics: ClampingScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: 15,
itemBuilder: (BuildContext context, int index) => Card(
child: Center(child: Text('Dummy Card Text')),
),
),
),
Text(
'Demo Headline 2',
style: TextStyle(fontSize: 18),
),
Card(
child: ListTile(title: Text('Motivation $int'), subtitle: Text('this is a description of the motivation')),
),
Card(
child: ListTile(title: Text('Motivation $int'), subtitle: Text('this is a description of the motivation')),
),
Card(
child: ListTile(title: Text('Motivation $int'), subtitle: Text('this is a description of the motivation')),
),
Card(
child: ListTile(title: Text('Motivation $int'), subtitle: Text('this is a description of the motivation')),
),
Card(
child: ListTile(title: Text('Motivation $int'), subtitle: Text('this is a description of the motivation')),
),
],
),
)`
Upvotes: 0
Reputation: 1091
You can add on top of Column
SingleChildScrollView
to load the entire attribute .
Then you can stop the scroll
in the second ListView
with this code
:
ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true, // Edit new line
.
.
),
In this case, you will have one vertical scroll
that follows SingleChildScrollView
and the page is completely animated.
Upvotes: 1
Reputation:
you can put your story listview in SliverAppBar, it will hide your story list when you scroll up. here's the link https://flutter.dev/docs/cookbook/lists/floating-app-bar
Upvotes: 2