skip to Main Content

The argument type ‘JsObject’ can’t be assigned to the parameter type ‘BuildContext’ for sliding up panel feature of PROFILE page for flutter program

  // Panel Body
 SingleChildScrollView _panelBody(ScrollController controller) {
   double hPadding = 40;
   return SingleChildScrollView(
               controller: controller,
               physics: const ClampingScrollPhysics(),
               child: Column(
                  children: <Widget>[
                    Container(
                      padding: EdgeInsets.symmetric(horizontal: hPadding),

                      height: MediaQuery.of(context).size.height * 0.35,
                                             ^ context is the one that sending error signals which is The argument type 'JsObject' can't be assigned to the parameter type 'BuildContext'. I imported the dart.js that it recommended yet it did not fix the error
                    )
                  ],
               ),
             );
 }

2

Answers


  1. Add context in the _panelBody function

    SingleChildScrollView _panelBody(ScrollController controller, BuildContext context) { // <----HERE
    

    Then wherever you use method _panelBody use as below code

    _panelBody(controller,context)
    
    Login or Signup to reply.
  2. You need to pass the buildContext in the _panelBody function.

     SingleChildScrollView _panelBody(ScrollController controller, BuildContext context) {
       double hPadding = 40;
       return SingleChildScrollView(
                   controller: controller,
                   physics: const ClampingScrollPhysics(),
                   child: Column(
                      children: <Widget>[
                        Container(
                          padding: EdgeInsets.symmetric(horizontal: hPadding),
                          height: MediaQuery.of(context).size.height * 0.35,
                        )
                      ],
                   ),
                 );
     }

    And call the widget as

    _panelBody(controller, context)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search