更改焦点上边框颜色的简单方法是什么? 我要专注
在边框中:Border.all(宽度:2,颜色:Colors.white)), 孩子:Icon(...
成为 颜色。黄色
MaterialButton(
padding: EdgeInsets.all(4.0),
focusColor: Colors.indigo,
elevation: 0.0,
//focusNode: myFocusNode,
child: Container(
child: new Align(
alignment: Alignment.bottomRight,
child: Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
border: Border.all(width: 2, color: Colors.white)),
child: Icon(
Icons.search,
color: Colors.white,
),
)),
),
onPressed: () async {},
)
答案 0 :(得分:0)
您可以按照以下代码进行操作。
import 'package:flutter/material.dart';
bool focus = false;
class teset extends StatefulWidget {
@override
State<StatefulWidget> createState() => teset_RunAppPageState();
}
class teset_RunAppPageState extends State<teset> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: MaterialButton(
padding: EdgeInsets.all(4.0),
focusColor: Colors.indigo,
elevation: 0.0,
//focusNode: myFocusNode,
child: Container(
child: new Align(
alignment: Alignment.bottomRight,
child: Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
border: Border.all(
width: 2, color: focus ? Colors.white : Colors.yellow)),
child: Icon(
Icons.search,
color: Colors.white,
),
)),
),
onPressed: () async {
setState(() {
focus = !focus;
});
},
),
);
}
}