1

このCustomScaffoldを再利用できるように、ボタンを含むカスタム Scaffold ウィジェットを作成したいと考えています。現在、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);
  }

}
4

1 に答える 1