Flutter 入门问题汇总

Auth:𝕃𝕖𝕠𝕏       Date:2023/12/25       Cat:编程       Word:共1030字

IOS模拟器无法弹出软键盘

修改模拟器配置,将模拟器中关于keyboard配置中去掉选项“connect Hardware keyboard”,即不使用电脑上的输入设备

具体如下:模拟器 -- 菜单 -- I/O -- keyboard -- connect Hardware Keyboard

Dart构造函数介绍

很多新手会写Fluuter,但对Dart语言一知半解,有必要了解下相关的知识:https://juejin.cn/post/6844903902563794958

如何防止 Dart 中类的实例化

如果您有一个仅包含静态方法和常量的 Dart 类,您很可能希望使该类不可实例化。但是,即使您不提供任何构造函数,Dart 也会默认为该类创建一个空构造函数,解决方案是创建一个私有构造函数。

```

class MyUtils { MyUtils._(); static void printMessage() { print('Woolha.com'); } }

```

如何找到iOS模拟器的目录

  1. 点击XCODE上方的window选择Devices ,打开设备一览,在上方选择模拟器,找到相应模拟器的 Identifier。
  2. 打开目录 /Users/用户名/Library(资源库)/Developer/CoreSimulator/Devices/,根据前面找到的 Identifier ,相应的目录就是模拟器的目录。

如何找到iOS模拟器中APP的目录

安装 path_provider ,通过在代码中打印输出目录地址

```

Directory documentsDirectory = await getApplicationDocumentsDirectory(); print(documentsDirectory.path);

```

iOS模拟器无法启动 unable to boot the simulator

For Mac Ventura 13.0 OS and higher -> Click apple logo on top left of your Mac

System Settings > search Storage > Developer

Then delete Xcode Caches

Don't use 'BuildContext's across async gaps. Try rewriting the code to not reference the 'BuildContext'.

在每次 await 操作后对 context 做一个判断, if (context.mounted) {...} ,在里面做后续的操作

《Flutter 入门问题汇总》留言数:0

发表留言