You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
62 lines
1.4 KiB
import 'package:flutter/material.dart'; |
|
|
|
/// 自定义 键盘 按钮 |
|
class CustomKbBtn extends StatefulWidget { |
|
final String text; |
|
|
|
CustomKbBtn({Key key, this.text, this.callback}) : super(key: key); |
|
final callback; |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return ButtonState(); |
|
} |
|
} |
|
|
|
class ButtonState extends State<CustomKbBtn> { |
|
///回调函数执行体 |
|
var backMethod; |
|
|
|
void back() { |
|
widget.callback('$backMethod'); |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
MediaQueryData mediaQuery = MediaQuery.of(context); |
|
var _screenWidth = mediaQuery.size.width; |
|
|
|
Widget button = MaterialButton( |
|
shape: RoundedRectangleBorder( |
|
borderRadius: BorderRadius.circular(5.0), side: BorderSide.none), |
|
elevation: 1, |
|
color: Color(0xFFFCFCFE), |
|
child: Text( |
|
widget.text, |
|
style: TextStyle(color: Color(0xff333333), fontSize: 20.0), |
|
), |
|
onPressed: back, |
|
); |
|
if (widget.text == "") { |
|
button = Container(); |
|
} else if (widget.text == "删除") { |
|
button = MaterialButton( |
|
onPressed: back, |
|
child: Center( |
|
child: Image.asset( |
|
"assets/image/icon_del.webp", |
|
width: 24, |
|
height: 18, |
|
fit: BoxFit.contain, |
|
), |
|
), |
|
); |
|
} |
|
return Container( |
|
height: 46.0, |
|
margin: EdgeInsets.all(3), |
|
width: (_screenWidth - 24) / 3, |
|
child: button, |
|
); |
|
} |
|
}
|
|
|