flutter_inner_drawer
Inner Drawer 是一种创建内部侧边栏(左/右)的简便方法,您可以在其中插入列表菜单或其他内容。
安装
将此添加到您的 package 的 pubspec.yaml 文件中
dependencies:
flutter_inner_drawer: "^0.2.2"
新版本 0.1.5 -> 0.2.0
动画类型
- 静态
- 线性 - _0.2.0 版本开始的线性动画行为有所不同_
- 二次方 (0.1.5 版本的线性)
演示


简单用法
import 'package:flutter_inner_drawer/inner_drawer.dart';
.
.
.
final GlobalKey<InnerDrawerState> _innerDrawerKey = GlobalKey<InnerDrawerState>();
@override
Widget build(BuildContext context)
{
return InnerDrawer(
key: _innerDrawerKey,
position: InnerDrawerPosition.start, // required
onTapClose: true, // default false
swipe: true, // default true
offset: 0.6, // default 0.4
colorTransition: Color.red, // default Color.black54
animationType: InnerDrawerAnimation.linear, // default static
innerDrawerCallback: (a) => print(a), // return bool
child: Material(
child: SafeArea(
child: Container(...)
)
),
// A Scaffold is generally used but you are free to use other widgets
// Note: use "automaticallyImplyLeading: false" if you do not personalize "leading" of Bar
scaffold: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false
)
.
.
)
or
CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
automaticallyImplyLeading: false
),
.
.
),
)
}
void _open()
{
_innerDrawerKey.currentState.open();
}
void _close()
{
_innerDrawerKey.currentState.close();
}
所有参数
- child - _内部小部件 (必需)_
- scaffold - _通常使用 Scaffold,但您也可以自由使用其他小部件 (必需)_
- position - _这控制用户应滑动打开和关闭 InnerDrawer 的方向 (必需)_
- offset - _抽屉宽度偏移量 (默认 0.4)_
- onTapClose - _布尔值 (默认 false)_
- swipe - _布尔值 (默认 true)_
- boxShadow - _打开的 Scaffold 的 BoxShado_
- colorTransition - _默认 Colors.black54_
- animationType - _static / linear / quadratic (默认 static)_
- innerDrawerCallback - _当 InnerDrawer 打开或关闭时调用的可选回调_
问题
如果您遇到问题,请提交 issue。Pull request 也非常欢迎。