|
一、 TextField设置高度后,文字无法居中
解决方案:
TextField(
style: TextStyle(
),
decoration: InputDecoration(
prefixIcon: ImageUtils.getImage("search")/*Icon(Icons.search)*/,
hintText: widget.hint,
fillColor: Color(0xfff1f1f2),
contentPadding: EdgeInsets.all(0),//设置输入内容垂直居中
border: OutlineInputBorder(
borderSide: BorderSide.none,
// borderRadius: BorderRadius.circular(20)
),
),
)
- 设置decoration属性,在InputDecoration中设置
contentPadding: EdgeInsets.all(0),。 - 在InputDecoration中设置border属性,不能直接设置
InputBorder.none,否则还是不能居中。
二、项目使用window.physicalSize和设定尺寸作比来做适配,奇怪的某些界面偶现的错乱问题
解决方案:(我的是由于项目中使用了隐藏导航栏await SystemChrome.setEnabledSystemUIOverlays([]);的原因,可能还有其他的因素会影响到window.physicalSize的获取计算问题),
void main() async {
return SentryUtil.wrap(() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations(
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
if (Platform.isIOS) {
await ScreenRotationiOS.changeScreenOrientation(
DeviceOrientationMask.Landscape);
}
Devices.init(width: 1080, height: 810);
runApp(MyApp(
appRoutes: routes,
home: HomeScreen(),
));
//这个需要放置在runApp后,不影响项目内部的window.physicalSize的获取
await SystemChrome.setEnabledSystemUIOverlays([]);
}, dsn: kDebugMode ? null : sentryDsn);
}
//这个需要放置在runApp后,不影响项目内部的window.physicalSize的获取 await SystemChrome.setEnabledSystemUIOverlays([]);
三、点击空白触发取消键盘
FocusScope.of(context).requestFocus(FocusNode());
四、软键盘把界面底部顶起,不让界面底部自动升起
Scaffold(
resizeToAvoidBottomPadding: false,
)
五、合并多个流做为一个stream
//yaml引入依赖 async
//使用StreamGroup.merge()
StreamBuilder(
stream: StreamGroup.merge(_streams),
builder:....,)
六、
|