Home > Software engineering >  Flutter Error - The argument type 'MaterialStateProperty<RoundedRectangleBorder>' ca
Flutter Error - The argument type 'MaterialStateProperty<RoundedRectangleBorder>' ca

Time:06-29

want to customize the button's default border radius but having the following error: "The argument type 'MaterialStateProperty' can't be assigned to the parameter type 'OutlinedBorder"

Padding(
              padding: const EdgeInsets.all(20.0),
              child: ElevatedButton(
                  style: ElevatedButton.styleFrom(
                      shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                          RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10.0))),
                      elevation: 0,
                      primary: Colors.white,
                      minimumSize: const Size.fromHeight(50)),
                  onPressed: () {
                    Navigator.pushNamed(context, '/home');
                    // Navigator.of(context).pushReplacementNamed('/home');
                  },
                  child: const Text(
                    "Start",
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 18,
                        color: Color.fromRGBO(86, 96, 49, 1)),
                  )),
            ),

CodePudding user response:

Just remove MaterialStateProperty.all( or replace your code with below.

 Padding(
  padding: const EdgeInsets.all(20.0),
  child: ElevatedButton(
      style: ElevatedButton.styleFrom(
          shape:RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(30.0),
          ),
          elevation: 0,
          primary: Colors.white,
          minimumSize: const Size.fromHeight(50)),
      onPressed: () {
        Navigator.pushNamed(context, '/home');
        // Navigator.of(context).pushReplacementNamed('/home');
      },
      child: const Text(
        "Start",
        style: TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: 18,
            color: Color.fromRGBO(86, 96, 49, 1)),
      )),
)
  • Related