Методы RaisedButton не определены

Хорошо, во-первых, извините за мой плохой английский, потому что я не из страны, основной язык которой - английский. Ок, вот моя проблема. сегодня и вчера я создаю новый проект и написал код в коде Visual Studio.

Вот мой исходный код:

    import 'package:flutter/material.dart';

    class Raisedbutton extends StatelessWidget {
      Widget build(BuildContext context) {
        return MaterialApp(
          title: "Raised Button",
          home: Scaffold(
            appBar: AppBar(
                title: Text("Latihan membuat Raised button"),
                backgroundColor: Colors.green),
            body: Center(
              child: Column(
                children: <Widget>[
                  Expanded(
                    child: Row(
                      children: <Widget>[
                        Text("1. Pizza"),
                        Text("2. Satay"),
                        Text("3. Spagethi"),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }

    class Raised extends StatelessWidget {
      Widget build(BuildContext context) {
        var button = Container(
          margin: EdgeInsets.only(top: 50.0),
          child: RaisedButton(
              child: Text("Click here"),
              color: Colors.blue,
              elevation: 5.0,
              onPressed: () {
                order(context);
              }),
        );
      }


  void order(BuildContext context) {
    var alert = AlertDialog(title:Text("CONGRATULATION", style: TextStyle(color: Colors.white, fontSize: 25.0),),content: Text("You got ZONK!!!"),);
  }
}

И да, мой исходный код RaisedButton получил ошибку, я не знал, где я ошибаюсь, и да, этот код - тот же код, что и мое турториальное видео, где в видео ничего нет. может кто подскажет где моя проблема? это в конфигурации? Я уже удалил весь пакет, включая код Visual Studio.

Спасибо за вашу помощь !

Где вы положили свой Raised и также показали мне main()

Blasanka 29.11.2018 05:46

может дело в написании? Имя класса - Raisedbutton с маленькой буквой «b», а ваше название - RaisedButton.

nonybrighto 29.11.2018 06:14

@nonybrighto no man его RaisedButton с большой буквы, вот ссылка docs.flutter.io/flutter/material/RaisedButton-class.html

Rishabh 29.11.2018 07:49

Прогнал ваш код в моей студии, ошибок не было - работает нормально.

anmol.majhail 29.11.2018 08:07
0
4
1 488
1

Ответы 1

RaisedButton теперь устарел и заменен на ElevatedButton. На основании документации:

FlatButton, RaisedButton, and OutlineButton have been replaced by TextButton, ElevatedButton, and OutlinedButton respectively. ButtonTheme has been replaced by TextButtonTheme, ElevatedButtonTheme, and OutlinedButtonTheme. The original classes will eventually be removed, please migrate code that uses them. There's a detailed migration guide for the new button and button theme classes in flutter.dev/go/material-button-migration-guide.

Другие вопросы по теме