Flutter底部滑动应用栏插件slidable_bottom_app_bar的使用
Flutter底部滑动应用栏插件slidable_bottom_app_bar的使用
预览
SlidableBottomAppBar(
hasCenterButton: true,
SlidableBottomAppBar(
hasCenterButton: false,
开始使用
在你的Flutter项目的pubspec.yaml
文件中添加以下依赖:
dependencies:
slidable_bottom_app_bar: ^1.0.1
然后运行 $ flutter pub get
。在你的库中添加以下导入:
import 'package:slidable_bottom_app_bar/slidable_bottom_app_bar.dart';
使用方法
使用方法是将它放在Scaffold
小部件的body
参数中,并将页面内容放在pageBody
属性中,如下面的示例所示:
return Scaffold(
body: SlidableBottomAppBar(
// 外观参数
shape: SlidableBottomAppBarShape.rounded,
color: Colors.blue,
buttonColor: Colors.blue,
maxHeight: screenSize.height * 0.5,
allowShadow: true,
// 主屏幕内容
pageBody: const SafeArea(
child: Center(
child: Text('页面内容'),
),
),
// SlidableBottomAppBar 的主体内容
body: Column(
children: const [
Center(
child: Text('内容'),
),
],
),
// 中心按钮的内容
buttonChild: const Icon(
Icons.refresh,
color: Colors.white,
),
// 中心按钮的点击事件
onButtonPressed: () {
// 做一些事情
},
// 底部应用栏的内容
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Icon(
Icons.home,
color: Colors.white,
),
SizedBox(
width: screenSize.width * 0.1,
),
const Icon(
Icons.local_activity,
color: Colors.white,
),
],
),
),
);
上述示例将产生以下结果:
形状
参数 shape
可以取三个值:
shape: SlidableBottomAppBarShape.rounded,
此值将产生以下效果:
shape: SlidableBottomAppBarShape.wave,
此值将产生以下效果:
shape: SlidableBottomAppBarShape.roundedCurved,
更多关于Flutter底部滑动应用栏插件slidable_bottom_app_bar的使用的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复