Flutter 中通过 RaisedButton 定义一个按钮。
return RaisedButton(
child: Text('女装'), textColor: Theme.of(context).accentColor, onPressed: (){
}, );
Flutter 2.x 以后新增了一些按钮组件 可以使用 ElevatedButton 替代 RaisedButton,也可以继续使用 RaisedButton(但目前貌似最新版无法使用RaisedButton了)
class MyButton extends StatelessWidget{
final String text;
const MyButton(this.text,{
Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ElevatedButton(
child: Text(this.text), onPressed: (){
}
);
}
}