**这是我的代码 我想要一个抗条裂的标题,它可以在滚动时固定并且新闻标题应该放在最前面 我希望在银条应用程序栏下方滚动时将我的容器固定在顶部,我希望将宽度固定到一定长度,然后在此处输入图像描述 这是我遇到的错误(https://drive.google.com/file/d/1CPGLHDcwuRJtgQSTODCvdAE8e3hkiDAE/view)
**
return Scaffold(
body: loading ? Center(
child: Container(
child: CircularProgressIndicator(),
),
)
: SafeArea(
child: PageView.builder(
itemCount: newsList.length,
itemBuilder: (context,index){
return(Container(
child: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
pinned: true,
snap: true,
backgroundColor: Colors.red,
floating: true,
expandedHeight: 350,
flexibleSpace: FlexibleSpaceBar(
background: Image.network(newsList[index].urlToImage,fit: BoxFit.fill,),
title: Text(this.category.toUpperCase(),style: TextStyle(color: Colors.white),),
),
),
SliverPersistentHeader(
pinned: true,
floating: false,
delegate: CustomSliverPersistentHeader(child:Container(
height: 200,
child:Text(newsList[index].title,style: TextStyle(fontSize: 35,fontWeight: FontWeight.w500),),
)),
),
SliverFillRemaining(
child:Container(
//color: Colors.red,
child: Column(
children: <Widget>[
Text(newsList[index].title),
SizedBox(
height: 20,
),
Text(newsList[index].description)
],
),
)
)
],
),
) );
}
),
)
);
}
}
class CustomSliverPersistentHeader extends SliverPersistentHeaderDelegate{
final Widget child;
enter code here
CustomSliverPersistentHeader({this.child});
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
return this.child;
}
@override
// TODO: implement maxExtent
double get maxExtent => 200;
@override
// TODO: implement minExtent
double get minExtent => 200;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
// TODO: implement shouldRebuild
return true;
}
}