【发布时间】:2018-11-17 08:56:26
【问题描述】:
假设我在屏幕的一侧有一个容器,我希望它始终存在,即使在通过不同屏幕导航时也是如此。
有什么方法可以实现吗?如果是,怎么做?
【问题讨论】:
假设我在屏幕的一侧有一个容器,我希望它始终存在,即使在通过不同屏幕导航时也是如此。
有什么方法可以实现吗?如果是,怎么做?
【问题讨论】:
这是一个有趣的问题。我可以给你一个解决方案,但不知道这样做是否正确。
在MaterialApp 小部件中有一个构建器参数,它提供整个屏幕视图作为参数,并且可以被另一个Widget 包裹起来。这是一个例子。
MaterialApp(
....
builder: (context, widget) {
return Stack(
children: [
_myPersistantWidget(), // you can add your widget. May be inside Positioned widget?
widget //this is the whole screen that we are wrapping in the stack
],
);
},
....
);
【讨论】: