The method 'RaisedButton' isn't defined for the class

lib/main.dart:90:15: Error: The getter ‘RaisedButton’ isn’t defined for the class ‘_girisState’.

  • ‘_girisState’ is from ‘package:flutterapp/main.dart’ (‘lib/main.dart’).
    Try correcting the name to the name of an existing getter, or defining a getter or field named ‘RaisedButton’.
    RaisedButton.icon(
    ^^^^^^^^^^^^
    lib/main.dart:99:15: Error: The method ‘RaisedButton’ isn’t defined for the class ‘_girisState’.
  • ‘_girisState’ is from ‘package:flutterapp/main.dart’ (‘lib/main.dart’).
    Try correcting the name to the name of an existing method, or defining a method named ‘RaisedButton’.
    RaisedButton(
    ^^^^^^^^^^^^

My code

              RaisedButton.icon(
                onPressed: () {
                  _handleSignIn();
                },
                color: Colors.blue,
                textColor: Colors.white,
                label: Text("Google Giris Yap"),
                icon: Icon(Icons.sentiment_very_satisfied),
              ),
              RaisedButton(
                child: Text("Daha Karpuz Kesecektik :("),
                color: Colors.blue,
                textColor: Colors.white,
                onPressed: () {
                  SystemChannels.platform.invokeMethod('SystemNavigator.pop');
                },

i think i should change the button but there’s a wrong with that, im not good with flutter can anyone help ?

i tried to change to elvated button but its didnt work

>Solution :

ElevatedButton don’t have exact same property as RaisedButton had.
But you can do everything which you were doing with RaisedButton like below

ElevatedButton(
        onPressed: () {
          _handleSignIn();
        },
       //Styles contains all the design related to button
        style: ButtonStyle(
          backgroundColor: MaterialStatePropertyAll(Colors.blue),
        ),
        //Child is basically what you want to display inside button It can be Text, Row, Column, or Icon.
        child: Row(
          children: const [
            Text("Google Giris Yap", style: TextStyle(color: Colors.white),),
            Icon(Icons.sentiment_very_satisfied),
          ],
        ),
      )

Leave a Reply