Flutter Errors
Failed to create platform view rendering surface
[VERBOSE-2:platform_view.cc(85)] Failed to create platform view rendering surface
Failed to create platform view rendering surface · Issue #70811 · flutter/flutter
Failed to create platform view rendering surface · Issue #88168 · flutter/flutter
以上三条信息最终指向的解决方式是 Xcode 的 bug,造成了误导。
This is fixed as of Xcode 13 beta 5. Closing.
最终发现原因是,我改了 storyboard 里的视图控制器的 Custom Class(由 FlutterViewController
改成了 MyFlutterViewController
),并且,MyFlutterViewController
的 viewDidLoad
方法里没有调用 [super viewDidLoad]
,导致视图无法正确加载……
Dart SDK is not configed
删掉根目录下的 .idea
目录,重新按照官网教程做一遍就好了。
注意 Dart SDK 要用这个路径呀:
MissingPluginException
MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)
因为不是一个引擎。
通过创建 FlutterViewController 来展示 flutter 页面,会隐式创建一个新的引擎。等于在主引擎做的注册插件和通道,在新的引擎都没有。
There are multiple observatory ports available.
Failed to create datagram socket
Oops; flutter has exited unexpectedly: "SocketException: Failed to create datagram socket (OS Error: Address already in use, errno = 48), address = , port = 5353".
开启了远程桌面 NoMachine 服务导致的,关闭后问题解决。
MediaQuery
MediaQuery 获取屏幕宽度为 0 的原因。
LFS
Encountered 30 files that should have been pointers, but weren't:
git lfs uninstall
git lfs install
iOS 14 以上 Debug 包无法从桌面启动
pub get failed
- 在
flutter pub get
之前运行一下flutter doctor
命令,让它去 下载 flutter_tools 即可 - 建议机器上面装了新版 flutter 后可以运行
flutter doctor
让它自动安装一些依赖,避免每次执行都安装
PlatformView 点击事件透传
webview response to gesture from the widget above it · Issue #58659 · flutter/flutter
50431040/flutter_gromore: flutter 插件:穿山甲 Gromore 广告插件
Skia 渲染 emoji 崩溃
App crashes when rendering emoji text · Issue #107509 · flutter/flutter · GitHub
add-to-app 模式下改 dart 代码不生效
beta 版本设置高刷崩溃
都是在 beta 版本:
Attaching to running flutter process doesn't highlight source paused on
Attaching to running flutter process doesn't highlight source paused on
xargs: dart: No such file or directory
代码自动格式化时遇到的错误。
最后发现是 git 工具没有把 .zshrc 里的路径读进来,导致 dart 命令找不到。
if [[ ! $PATH =~ "flutter" ]]; then
if [ -f "$HOME/.bashrc" ]; then
echo '载入.bashrc'
source $HOME/.bashrc
fi
if [ -f "$HOME/.zshrc" ]; then
echo '载入.zshrc'
source $HOME/.zshrc
fi
fi
IO thread's priority
setThreadPriority: | Apple Developer Documentation:0 为最低,1 为最高。
switch (config.priority) {
case fml::Thread::ThreadPriority::BACKGROUND: {
[[NSThread currentThread] setThreadPriority:0];
break;
}
case fml::Thread::ThreadPriority::NORMAL: {
[[NSThread currentThread] setThreadPriority:0.5];
break;
}
case fml::Thread::ThreadPriority::RASTER:
case fml::Thread::ThreadPriority::DISPLAY: {
[[NSThread currentThread] setThreadPriority:1.0];
break;
}
}
Unexpected top padding in ListView put inside scaffold with no appBar
源码解释:
/// By default, [ListView] will automatically pad the list's scrollable
/// extremities to avoid partial obstructions indicated by [MediaQuery]'s
/// padding. To avoid this behavior, override with a zero [padding] property.
///
Android Studio 断点断不上
重启 Android Studio 好了,但是有些函数某些行还是会断点断不上。
type 'int' is not a subtype of type 'double'
涉及到终端到 Flutter 数据传递时,不要随便改数据类型,这个值是 Android 终端传的,iOS 直接改了没验证,结果启动页面就 exception
An error occurred while processing the post-install hook of the Podfile
fix: continue->next in Ruby script by jmagman · Pull Request #104296 · flutter/flutter
Incorrect use of ParentDataWidget
Under ListView
don't use Spacer
Widget.
Expanded
cannot be used inside a Stack
. You should use Expanded
only within a Column
, Row
or Flex
.
Waiting for connection
重新 make ios-debug DART_ONLY=1
再 make ios-attach
就可以连上了。
RenderConstrainedBox object was given an infinite size during layout.
有个需求,需要在 Column 中放个 Webview,用到 RenderUiKitView,根据错误信息描述,原因是在渲染控件时,WebView 是无限大的,在 Column 中是不允许这样的。我们只需要使用 Expanded 将其包裹即可。
App.framework 如何符号化
bugly 上 App.framework 看不到符号
Feat: dSYM debug info for iOS & macOS builds by vaind · Pull Request #101586 · flutter/flutter
type 'FlexParentData' is not a subtype of type 'StackParentData' in type cast
调用栈顶:#0 Positioned.applyParentData (package:flutter/src/widgets/basic.dart:4068)
原因:Row
里面用了 Positioned
。注意:
- Under
ListView
don't useSpacer
Widget - don't use
Positioned
underRow
orColumn
Expanded
can only use it must be a descendant ofColumn
,Row
,Flex
await platform.invokeMethod 没反应
// ❌这个写法有问题,类型不正确,但Flutter没有报错也没有提示,现象上看就是await永远不会结束
final List<String> result = await platform.invokeMethod(NATIVE_METHOD_GET_STRING_LIST, {"key": key});
// ✅改成这个写法后正常
final result = await platform.invokeMethod(NATIVE_METHOD_GET_STRING_LIST, {"key": key});
Xcode 16 编译 3.0.4 Flutter 问题
where flutter
找到本地 Flutter SDK,找到文件:flutter/packages/flutter_tools/lib/src/build_system/targets/ios.dart
注释掉 -fembed-bitcode-marker
,然后删除flutter/bin/cache/flutter_tools.snapshot
和flutter/bin/cache/flutter_tools.stamp
执行 flutter doctor
重新编译 flutter_tools