底部是普通按钮
时间: 2024-02-23 14:59:23 浏览: 14
如果你想要底部是一个普通按钮而不是 BottomNavigationBar,可以将它放在 Scaffold 的 bottom 属性中,如下所示:
```dart
import 'package:flutter/material.dart';
class MyPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My App'),
),
body: Center(
child: Text('Content'),
),
bottomNavigationBar: Container(
height: 50,
child: RaisedButton(
onPressed: () {
// 处理按钮点击事件
},
child: Text('Button'),
),
),
);
}
}
```
在这个示例中,我们将底部按钮放在了 Scaffold 的 bottom 属性中,使用了一个 Container 来设置其高度,并使用了一个 RaisedButton 来作为底部按钮。
这样,我们就实现了一个顶部中部底部都是普通控件的页面布局。