【发布时间】:2020-08-12 07:13:36
【问题描述】:
我希望能够在用户向上滚动时让设置标题(位于灵活空格键中)移动到中心。我怎样才能做到这一点?
我在滚动时链接了当前屏幕的视频。正如您所看到的,当用户向上滚动时,设置标题会转到左侧而不是中心。
这是我的屏幕代码(并非全部只是相关的部分):
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(slivers: <Widget>[
SliverAppBar(
title: Row(
children: <Widget>[
Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
child: IconButton(
onPressed: () =>
Navigator.pop(context),
//controller.toggle();
icon: Image.asset('assets/UI/menu.png')),
),
],
)
],
),
expandedHeight: 145.0,
backgroundColor: Colors.white,
//floating: true,
pinned: true,
elevation: 0.0,
flexibleSpace: FlexibleSpaceBar(
title: Row(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(80, 0, 0, 0),
child: Text(
'Settings',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black,
fontFamily: 'AvenirNext',
fontWeight: FontWeight.w600,
fontSize: 22.0),
)),
],
),
background: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(20, 40, 32, 0),
child: Text(
'Change Settings',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.black54,
fontFamily: 'AvenirNext',
fontWeight: FontWeight.w300,
fontSize: 16.0),
)),
],
),
),
),
【问题讨论】:
标签: flutter