在物理设备和模拟器上进行了测试。
众所周知,textSelectionHandleColor 已被弃用。因此,我决定对我的应用程序代码进行一些更改,不幸的是,selectionHandleColor 仍然是我们创建新应用程序时获得的默认蓝色。
TextSelectionTheme(
data: TextSelectionThemeData(
cursorColor: kLightGreen,
selectionHandleColor: kLightGreen,
selectionColor: kGrey),
child: TextField(
keyboardType: TextInputType.number,
style: TextStyle(
color: kOffWhite,
letterSpacing: 1.5,
),
decoration: InputDecoration(
labelText: 'Label',
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: kLightGreen),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: kLightGreen),
),
hintText: 'Hint',
hintStyle: TextStyle(
color: kOffWhite,
letterSpacing: 1.5,
),
labelStyle: TextStyle(
color: kLightGreen,
letterSpacing: 1.5,
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
除手柄颜色外,光标颜色、选择颜色均已更改。我已尝试了一切可能的方法来更改文本选择手柄颜色。
我有一个卡片列表,但是当我更改卡片的宽度时,它仍然采用与父容器相同的宽度。我尝试过用大小合适的盒子或容器包装列表视图、卡片甚至滚动视图,但没有任何效果。
Container(
height: MediaQuery.of(context).size.height * 0.6,
width: MediaQuery.of(context).size.width * 0.8,
decoration: BoxDecoration(
color: kWhiteColor,
borderRadius: BorderRadius.all(
Radius.circular(MediaQuery.of(context).size.height * 0.02)),
),
child: Padding(
padding:
EdgeInsets.all(MediaQuery.of(context).size.height * 0.015),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
return SizedBox(
width: MediaQuery.of(context).size.width*0.001,
height: MediaQuery.of(context).size.height*0.3,
child: Card(
color: Colors.black,
),
);
},
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
白卡后面是父容器,或者我们可以说是最外层的容器。