Flutter 定义一个按钮

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: (){
    
    
}
);
}
}

猜你喜欢

转载自blog.csdn.net/weixin_46136019/article/details/129590235