Flutter Navigator "Context argument type cannot be assigned to the 'Buildcontext' parameter type"

Asked

Viewed 32 times

0

I’m trying to navigate to another page on the flutter, so I insert the line:

Navigator.push(context, Materialpageroute(Builder: (context) => Loginpage()));

however context of that error:

The argument type 'Jsobject' can’t be Assigned to the Parameter type 'Buildcontext'.

someone there could have a solution?

import 'package:flutter/material.dart';
import 'package:untitled/src/componentes/cardCarrinho.dart';
import 'package:untitled/src/pages/loginPage.dart';

class carrinhoPage extends StatefulWidget{
  @override
  _carrinhoPageState createState() => _carrinhoPageState();

}

class _carrinhoPageState extends State<carrinhoPage> {
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: ListView(
          padding: EdgeInsets.symmetric(horizontal: 10.0),
          scrollDirection: Axis.vertical,
          children: <Widget>[
            CardCarrinho(),
            CardCarrinho(),
            CardCarrinho(),
          ]

      ),

      bottomNavigationBar: _TotalContainer(),
    );
  }
}
    Widget _TotalContainer(){
      return Container(
        height: 185.0,
        padding: EdgeInsets.only(
          left: 10.0,
          right: 10.0,
        ),
        margin: EdgeInsets.only(
          top: 30.0,
        ),
        child: Column(
          children: <Widget>[
            Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget> [
                   Text(
                      "Subtotal",
                      style: TextStyle(
                        color: Color(0xFF9BA7C6),
                        fontSize: 16.0,
                        fontWeight: FontWeight.bold),
                        ),
                    Text(
                        "23,0",
                        style: TextStyle(
                          color: Color(0xFF9BA7C6),
                          fontSize: 16.0,
                          fontWeight: FontWeight.bold),
                        ),
                    ],
                  ),
                 SizedBox(
                  height: 10.0,
                ),
               Row(
                  mainAxisSize: MainAxisSize.max,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    Text(
                      "Taxa de Entrega",
                          style: TextStyle(
                        color: Color(0xFF9BA7C6),
                            fontSize: 16.0,
                            fontWeight: FontWeight.bold),
                ),
                 Text(
                 "3,00",
                   style: TextStyle(
                       color: Color(0xFF9BA7C6),
                       fontSize: 16.0,
                       fontWeight: FontWeight.bold),
                 ),
                  ],
                ),
                SizedBox(
                  height: 10.0,
                ),
                Divider(
                  height: 2.0,
                ),
                SizedBox(
                  height: 10.0,
                ),
          Row(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Text(
                "Total",
                style: TextStyle(
                    color: Color(0xFF9BA7C6),
                    fontSize: 16.0,
                    fontWeight: FontWeight.bold),
              ),
              Text(
                "26,00",
                style: TextStyle(
                    color: Color(0xFF9BA7C6),
                    fontSize: 16.0,
                    fontWeight: FontWeight.bold),
              ),
          ],
        ),
        SizedBox(
          height: 10.0,
        ),
        GestureDetector(
      onTap: () {
        Navigator.pop(context).push(MaterialPageRoute(builder: (BuildContext context)  => LoginPage()));
          },
            child: Container(
            height: 50.0,
            decoration: BoxDecoration(
                color: Colors.indigo,
                borderRadius: BorderRadius.circular(10.0),
      ),
             child: Center(
              child: Text(
                "Finalizar Pagamento",
              style: TextStyle(
                  color: Color(0xFF9BA7C6),
                  fontSize: 18.0,
                  fontWeight: FontWeight.bold),
            ),
          ),
         ),
        ),
        SizedBox(
          height: 20.0,

  • Could you show the code? See if this helping

  • Navigator.of(context). push(Materialpageroute(Builder: (Buildcontext) => Loginpage()); },

  • This line of code serves to navigate between windows...but for some reason I do not know what the context of the error is.

  • How the error message contains 'JsObject' then in this code posted it is not possible to identify the cause. Locate in your code. It is possible that it is a loginPage.dart expect some parameter.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.