Flutter 更改点击时文本字段的边框颜色-颤振
这个问题可能看起来很简单,但每当我点击文本字段时,它就会自动在文本字段周围出现一个蓝色边框,正如您在所附的图像中看到的那样。我尝试过改变我这边各种属性的颜色,但似乎没有任何效果 我正在尝试将边框颜色更改为颜色。绿色 我的代码在下面-Flutter 更改点击时文本字段的边框颜色-颤振,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,这个问题可能看起来很简单,但每当我点击文本字段时,它就会自动在文本字段周围出现一个蓝色边框,正如您在所附的图像中看到的那样。我尝试过改变我这边各种属性的颜色,但似乎没有任何效果 我正在尝试将边框颜色更改为颜色。绿色 我的代码在下面- class MainMap extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: Theme
class MainMap extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(fontFamily: 'Quicksand',),
home: Map(),
);
}
}
// ----> Stateful Widget <-----
class Map extends StatefulWidget {
@override
_MapState createState() => _MapState();
}
class _MapState extends State<Map> {
LatLng currentLatLng;
Completer<GoogleMapController> _controller = Completer();
@override
void initState(){
super.initState();
Geolocator.getCurrentPosition().then((currLocation){
setState((){
currentLatLng = new LatLng(currLocation.latitude, currLocation.longitude);
});
});
}
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
return new Scaffold(
body: Stack(
children: [
currentLatLng == null ?
Center(child: CircularProgressIndicator(),) :
GoogleMap(
myLocationEnabled: true,
myLocationButtonEnabled: false,
mapType: MapType.normal,
zoomControlsEnabled: false,
initialCameraPosition: CameraPosition(target: currentLatLng, zoom: 15),
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
// ------> TEXT FIELD CODE IS BELOW <---------
Container(
margin: EdgeInsets.symmetric(horizontal: mediaQuery.size.width * 0.05, vertical: (mediaQuery.padding.top + 20)),
child: TextField(
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold,),
cursorColor: Colors.white,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(15),
focusColor: Colors.white,
prefixIcon: Image.asset("assets/icons/search.png",scale: 15,),
suffixIcon: Image.asset("assets/icons/profile.png",scale: 14,),
filled: true,
fillColor: AppColors.darkGreenSearch,
hintText: "Location",
hintStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
border: new OutlineInputBorder(
borderRadius: const BorderRadius.all(const Radius.circular(50.0)),
borderSide: BorderSide(color: AppColors.darkGreen,),
),
),
),
)
]),
class MainMap扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
主题:主题数据(fontFamily:‘流沙’,),
主页:Map(),
);
}
}
//--->有状态小部件\u MapState();
}
类映射状态扩展状态{
LatLng-currentLatLng;
Completer _controller=Completer();
@凌驾
void initState(){
super.initState();
Geolocator.getCurrentPosition().then((当前位置){
设置状态(){
currentLatLng=新LatLng(currLocation.latitude,currLocation.longitude);
});
});
}
@凌驾
小部件构建(构建上下文){
final mediaQuery=mediaQuery.of(上下文);
归还新脚手架(
主体:堆栈(
儿童:[
currentLatLng==null?
居中(子项:CircularProgressIndicator(),):
谷歌地图(
myLocationEnabled:对,
myLocationButtonEnabled:false,
mapType:mapType.normal,
ZoomControl启用:false,
initialCameraPosition:CameraPosition(目标:CurrentLatling,缩放:15),
onMapCreated:(谷歌地图控制器){
_控制器。完成(控制器);
},
),
//------>文本字段代码如下所示,可能与已工作的代码重复。非常感谢@RukshanJSGreat,欢迎使用!