bindDrawerContext method
绑定抽屉上下文(仅抽屉路由栈可用)
重要:必须传入 Scaffold 子组件的 context,不是根 context
示例:
Scaffold(
endDrawer: Builder(
builder: (context) {
// 在这里绑定 context
drawerRouter.bindDrawerContext(context);
return Container(
width: 300,
child: drawerRouter.build(context),
);
},
),
);
Implementation
void bindDrawerContext(BuildContext context) {
if (isDrawerStack) {
_drawerContext = context;
} else {
debugPrint('Warning: bindDrawerContext() should only be called on drawer stack');
}
}