Flutter

Flutter常见问题汇总

2019-12-11  本文已影响0人  Lcc不想混_b503

Flutter常见问题汇总

目录

  1. Mac os 10.15 运行‘idevice_id’无法验证开发者
  2. json数据转换
  3. TextField键盘显示隐藏
  4. 横竖屏设置
  5. TextField光标文字焦点不对齐问题
  6. ios打包白屏
  7. 图片充满父视图
  8. 运行报错:Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.

解决方案

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

替换为自己的路径

// 使用范例:
var list = json.decode(widget.itemBean.formDefaultValue);
  var items = (list as List).cast().map((value) {
  return Bean.formJson(value);
}).toList();
// 显示键盘
focusNode.requestFocus();
// 隐藏键盘
focusNode.unfocus();
SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown
  ]);
runApp(MyApp());
TextField(
   style: TextStyle(textBaseline: TextBaseline.alphabetic),
)
  1. ios打包白屏
flutter build ios --release
  1. 图片充满父视图
ConstrainedBox(
        child: Image.asset(
                  AssetImages.start2,
                  fit: BoxFit.cover,
                  ),
        constraints: new BoxConstraints.expand(),
       )
  1. 运行报错:Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
void main() {
  // 加上这句即可
  WidgetsFlutterBinding.ensureInitialized();
  //
  runApp(MyApp());
}
上一篇下一篇

猜你喜欢

热点阅读