对齐 appBar 下面的按钮,没有任何 space 颤动
Align buttons below appBar without any space in flutter
我想将按钮对齐到 appBar 的正下方,但我得到的是:
我想删除按钮和 appBar 之间的 space。我怎样才能做到这一点?
这是代码:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Home',
),
),
body: Column(
children: <Widget>[
Row(
children: <Widget>[
Column(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width*0.5,
child: RaisedButton(
onPressed: (){},
child: Text('SORT'),
),
)
],
),
Column(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width*0.5,
child: RaisedButton(
onPressed: (){},
child: Text('FILTER'),
),
)
],
)
],
),
],
),
);
}
}
在 RaisedButton 中,添加此参数:
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
使用小部件对齐父级:
appBar: AppBar(
title: Align(
alignment: Alignment.center
Text(
'Home',
),
),
),
我想将按钮对齐到 appBar 的正下方,但我得到的是:
我想删除按钮和 appBar 之间的 space。我怎样才能做到这一点?
这是代码:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Home',
),
),
body: Column(
children: <Widget>[
Row(
children: <Widget>[
Column(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width*0.5,
child: RaisedButton(
onPressed: (){},
child: Text('SORT'),
),
)
],
),
Column(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width*0.5,
child: RaisedButton(
onPressed: (){},
child: Text('FILTER'),
),
)
],
)
],
),
],
),
);
}
}
在 RaisedButton 中,添加此参数:
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
使用小部件对齐父级:
appBar: AppBar(
title: Align(
alignment: Alignment.center
Text(
'Home',
),
),
),