Хорошо, во-первых, извините за мой плохой английский, потому что я не из страны, основной язык которой - английский. Ок, вот моя проблема. сегодня и вчера я создаю новый проект и написал код в коде 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.
Спасибо за вашу помощь !
может дело в написании? Имя класса - Raisedbutton с маленькой буквой «b», а ваше название - RaisedButton.
@nonybrighto no man его RaisedButton с большой буквы, вот ссылка docs.flutter.io/flutter/material/RaisedButton-class.html
Прогнал ваш код в моей студии, ошибок не было - работает нормально.
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.
Где вы положили свой
Raisedи также показали мнеmain()