我怎样才能让底部FAB像下面的图片?
这是我当前的代码示例:
class _ItemDetailsState extends State<ItemDetails> {
@override
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height * 0.42;
return Scaffold(
body: Stack(children: <Widget>[
CustomScrollView(
slivers: <Widget>[
...
],
),
Positioned(
bottom: 0,
child: FloatingActionButton(
elevation: 4,
onPressed: () {},
child: Text("SAVE THE CHANGES"),
),
))
]));
}
}
我尝试了很多但没有运气:(有什么解决方案吗?谢谢你的建议:)
无法设置 FAB 的大小。相反,您必须使用RawMaterialButton
, 复制 FAB 的默认属性并更改大小:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
CustomScrollView(
slivers: <Widget>[
...
],
),
RawMaterialButton(
elevation: 6,
highlightElevation: 12.0,
constraints: BoxConstraints(
minHeight: 48.0,
minWidth: double.infinity,
maxHeight: 48.0,
),
fillColor: Theme.of(context).accentColor,
textStyle: Theme.of(context).accentTextTheme.button.copyWith(
color: Theme.of(context).accentIconTheme.color,
letterSpacing: 1.2,
),
child: Text("SAVE THE CHANGE"),
onPressed: () {},
)
],
),
);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句