我想创建一个包含按钮的自定义 Scaffold 小部件,以便我可以重用这个CustomScaffold。目前,我需要在 Scaffold 的构造函数中指定每个参数作为我的输入参数。有没有更好的方法来扩展小部件?
class CustomScaffold {
// if I want to have fully customized Scaffold, I need to have the following (duplicate) parameters exactly the same what Scaffold defined
// Key key,
// this.appBar,
// this.body,
// this.floatingActionButton,
// this.floatingActionButtonLocation,
// this.floatingActionButtonAnimator,
// this.persistentFooterButtons,
// this.drawer,
// this.endDrawer,
// this.bottomNavigationBar,
// this.bottomSheet,
// this.backgroundColor,
// this.resizeToAvoidBottomPadding = true,
// this.primary = true,
static Scaffold createCustomScaffold({@required AppBar appBar, Widget body}) {
final Widget cart = SafeArea(
child: Align(
alignment: Alignment.bottomCenter,
child: RaisedButton(
child: new Text(""),
color: Colors.amber,
onPressed: () {
print("Hello");
},
)
)
);
final Widget stack = Stack(
children: <Widget>[
body,
cart
],
);
return Scaffold(appBar: appBar,
body: stack);
}
}