Flutter常见问题汇总
2019-12-11 本文已影响0人
Lcc不想混_b503
Flutter常见问题汇总
目录
- Mac os 10.15 运行‘idevice_id’无法验证开发者
- json数据转换
- TextField键盘显示隐藏
- 横竖屏设置
- TextField光标文字焦点不对齐问题
- ios打包白屏
- 图片充满父视图
- 运行报错:Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
解决方案
-
Mac os 10.15 运行‘idevice_id’无法验证开发者
1576138438797.jpg
-
sudo xattr -d com.apple.quarantine [your_path]/flutter/bin/cache/artifacts/libimobiledevice/idevice_id
sudo xattr -d com.apple.quarantine [your_path]/flutter/bin/cache/artifacts/libimobiledevice/ideviceinfo
sudo xattr -d com.apple.quarantine [your_path]/flutter/bin/cache/artifacts/libimobiledevice/idevicesyslog
sudo xattr -d com.apple.quarantine [your_path]/flutter/bin/cache/artifacts/usbmuxd/iproxy
替换为自己的路径
- json数据转换
json_to_dart
- json数据转换
// 使用范例:
var list = json.decode(widget.itemBean.formDefaultValue);
var items = (list as List).cast().map((value) {
return Bean.formJson(value);
}).toList();
- TextField键盘显示隐藏
// 显示键盘
focusNode.requestFocus();
// 隐藏键盘
focusNode.unfocus();
- 横竖屏设置
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown
]);
runApp(MyApp());
- TextField光标文字焦点不对齐问题
TextField(
style: TextStyle(textBaseline: TextBaseline.alphabetic),
)
- ios打包白屏
- 在项目下运行:
flutter build ios --release
- 在Xcode中打开项目, Product -> Archive 即可
- 图片充满父视图
ConstrainedBox(
child: Image.asset(
AssetImages.start2,
fit: BoxFit.cover,
),
constraints: new BoxConstraints.expand(),
)
- 运行报错:Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
void main() {
// 加上这句即可
WidgetsFlutterBinding.ensureInitialized();
//
runApp(MyApp());
}