Search code examples
flutterscaffold

The argument for the named parameter 'body' was already specified.What we should do when we have two "bodys' in a scaffold in flutter


Error: The argument for the named parameter 'body' was already specified.What we should do when we have two "bodys' in a scaffold in flutter

 Widget build(BuildContext context) {
          return Scaffold(
            appBar: AppBar(
             title: Text(widget.title),
                 ),
               body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Flexible(
                child: gridView(),
              )
            ],
          ),
        ),

        body: SingleChildScrollView(
              child : Container(
               child: Padding(
                padding: const EdgeInsets.all(5),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(
                      "Enter the Device Details",
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 30,
                        fontWeight: FontWeight.bold,
                      ),
                    ),

Solution

  • Maybe something like this:

     @override
     Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text(widget.title)),
            body: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  Flexible(
                    child: child: gridView(),
                  ),
                  Container(
                   child: Padding(
                    padding: const EdgeInsets.all(5),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Text(
                          "Enter the Device Details",
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 30,
                            fontWeight: FontWeight.bold,
                          )
                        )
                      ]
                    )
                   )
                  ),
                ],
              ),
            )
        );
      }