英文:
Flutter iOS build/run error: widgets/context_menu_button_item.dart:49:9: Error: Type 'VoidCallback' not found
问题
我可以重现以下简单步骤的问题:
flutter create ios_test
cd ios_test
flutter run
版本信息:
Flutter 3.10.5 • 稳定通道 • https://github.com/flutter/flutter.git
框架 • 修订版 796c8ef792(3周前) • 2023年06月13日 15:51:02 -0700
引擎 • 修订版 45f6e00911
工具 • Dart 3.0.5 • DevTools 2.23.1
Dart SDK 版本:3.0.5(稳定版)(2023年6月12日 18:31:49 +0000)在 "macos_arm64"
flutter -v doctor
[✓] Flutter(稳定通道,3.10.5,在 macOS 13.4 22F66 darwin-arm64 上,区域设置为 en-US)
• Flutter 版本 3.10.5,通道 stable,位于 /Applications/flutter
• 上游存储库 https://github.com/flutter/flutter.git
• 框架修订版 796c8ef792(3周前),2023年06月13日 15:51:02 -0700
• 引擎修订版 45f6e00911
• Dart 版本 3.0.5
• DevTools 版本 2.23.1
[✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 34.0.0)
• Android SDK 位于 /Users/marku/Library/Android/sdk
• 平台 android-34,构建工具 34.0.0
• Java 二进制文件位于:/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java 版本 OpenJDK Runtime Environment(构建 17.0.6+0-17.0.6b802.4-9586694)
• 所有 Android 许可证已接受。
[✓] Xcode - 为 iOS 和 macOS 开发(Xcode 14.3.1)
• Xcode 位于 /Applications/Xcode.app/Contents/Developer
• 构建 14E300c
• CocoaPods 版本 1.12.1
[✓] Chrome - 为 Web 开发
• Chrome 位于 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio(版本 2022.2)
• Android Studio 位于 /Applications/Android Studio.app/Contents
• 可以从以下位置安装 Flutter 插件:
🌐 https://plugins.jetbrains.com/plugin/9212-flutter
• 可以从以下位置安装 Dart 插件:
🌐 https://plugins.jetbrains.com/plugin/6351-dart
• Java 版本 OpenJDK Runtime Environment(构建 17.0.6+0-17.0.6b802.4-9586694)
[✓] Visual Studio Code(版本 1.79.2)
• Visual Studio Code 位于 /Applications/Visual Studio Code.app/Contents
• Flutter 扩展版本 3.66.0
[✓] 已连接的设备(3 可用)
• iPhone 14(移动设备) • A9282848-729E-41F9-BC77-591834D5DAD2 • iOS • com.apple.CoreSimulator.SimRuntime.iOS-16-4(模拟器)
• macOS(桌面) • macos • darwin-arm64 • macOS 13.4 22F66 darwin-arm64
• Chrome(Web) • chrome • web-javascript • Google Chrome 114.0.5735.198
[✓] 网络资源
• 所有预期的网络资源都可用。
• 未发现问题!
有时在尝试在 Xcode 中构建项目后会出现稍有不同的错误:
[ +2 毫秒] 无法构建 iOS 应用程序
[ ] 错误(Xcode):[ +520 毫秒] /Applications/flutter/packages/flutter/lib/src/services/text_input.dart:713:1: 错误:未找到类型 'TextAffinity'。
[ +1 毫秒] 无法为模拟器构建应用程序。
[ ] 在 iPhone 14 上启动应用程序时出错。
[ +1 毫秒] "flutter run" 耗时 10,603 毫秒。
尝试升级 Flutter 包并运行 dart fix
。
尝试在 Xcode 中编译项目会出现不同的错误消息。
英文:
I can reproduce the issue with the following simple steps:
flutter create ios_test
cd ios_test
flutter run
Versions:
Flutter 3.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 796c8ef792 (3 weeks ago) • 2023-06-13 15:51:02 -0700
Engine • revision 45f6e00911
Tools • Dart 3.0.5 • DevTools 2.23.1
Dart SDK version: 3.0.5 (stable) (Mon Jun 12 18:31:49 2023 +0000) on "macos_arm64"
flutter -v doctor
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-US)
• Flutter version 3.10.5 on channel stable at /Applications/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (3 weeks ago), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/marku/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.79.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.66.0
[✓] Connected device (3 available)
• iPhone 14 (mobile) • A9282848-729E-41F9-BC77-591834D5DAD2 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.4 22F66 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 114.0.5735.198
[✓] Network resources
• All expected network resources are available.
• No issues found!
Sometimes it gets a slightly different error (after trying to build the project in Xcode):
[ +2 ms] Failed to build iOS app
[ ] Error (Xcode): [ +520 ms] /Applications/flutter/packages/flutter/lib/src/services/text_input.dart:713:1: Error: Type 'TextAffinity' not found.
[ +1 ms] Could not build the application for the simulator.
[ ] Error launching application on iPhone 14.
[ +1 ms] "flutter run" took 10,603ms.
Tried upgrading flutter packages and running dart fix
.
Trying to compile the project in Xcode fails with different error messages.
答案1
得分: 0
这似乎与Flutter 3.10.5或Dart 3.0.5相关的问题。当我使用Flutter 3.7.12创建一个新项目并在其中运行flutter run
时,应用程序在模拟器中启动顺利。
英文:
This seems to be an issue related to Flutter 3.10.5 or Dart 3.0.5. When I create a new project with Flutter 3.7.12 and call flutter run
in it, the app starts up smoothly in the simulator.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论