My flutter app is not running after adding screenshot package.

huangapple go评论86阅读模式
英文:

My flutter app is not running after adding screenshot package

问题

在我的Flutter应用程序中添加了截图包后,无法构建我的应用程序,出现以下错误:

  1. 错误:未定义名称 'View'
  2. screenshot.dart:154
  3. context == null ? fallBackView : View.maybeOf(context) ?? fallBackView;
  4. ^^^^
  5. 错误:没有名为 'view' 的命名参数。
  6. screenshot.dart:164
  7. view: view,
  8. ^^^^
  9. /C:/src/FlutterSDK/flutter/packages/flutter/lib/src/rendering/view.dart:68:3: 上下文:找到此候选项,但参数不匹配。
  10. RenderView({
  11. ^^^^^^^^^^
  12. 目标 kernel_snapshot 失败:异常
  13. 2
  14. 失败:构建失败,出现异常。
  15. * 位置:
  16. 脚本 'C:\src\FlutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle' 1151
  17. * 出现了什么问题:
  18. 任务 ':app:compileFlutterBuildDebug' 执行失败。
  19. > 进程 '命令 'C:\src\FlutterSDK\flutter\bin\flutter.bat'' 以非零退出值 1 结束
  20. * 尝试:
  21. > 使用 --stacktrace 选项运行以获取堆栈跟踪。
  22. > 使用 --info --debug 选项运行以获取更多日志输出。
  23. > 使用 --scan 选项运行以获取完整的见解。
  24. * 获取更多帮助:https://help.gradle.org
  25. 6s 内构建失败
  26. 异常:Gradle 任务 assembleDebug 以退出码 1 失败
  27. 有什么建议可以提供吗?提前感谢您。
  28. <details>
  29. <summary>英文:</summary>
  30. After adding the screenshot package on my flutter app,my app can not be build and it gives me this error :
  31. : Error: Undefined name &#39;View&#39;.
  32. screenshot.dart:154
  33. context == null ? fallBackView : View.maybeOf(context) ?? fallBackView;
  34. ^^^^
  35. : Error: No named parameter with the name &#39;view&#39;.
  36. screenshot.dart:164
  37. view: view,
  38. ^^^^
  39. /C:/src/FlutterSDK/flutter/packages/flutter/lib/src/rendering/view.dart:68:3: Context: Found this candidate, but the arguments don&#39;t match.
  40. RenderView({
  41. ^^^^^^^^^^
  42. Target kernel_snapshot failed: Exception
  43. 2
  44. FAILURE: Build failed with an exception.
  45. * Where:
  46. Script &#39;C:\src\FlutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle&#39; line: 1151
  47. * What went wrong:
  48. Execution failed for task &#39;:app:compileFlutterBuildDebug&#39;.
  49. &gt; Process &#39;command &#39;C:\src\FlutterSDK\flutter\bin\flutter.bat&#39;&#39; finished with non-zero exit value 1
  50. * Try:
  51. &gt; Run with --stacktrace option to get the stack trace.
  52. &gt; Run with --info or --debug option to get more log output.
  53. &gt; Run with --scan to get full insights.
  54. * Get more help at https://help.gradle.org
  55. BUILD FAILED in 6s
  56. Exception: Gradle task assembleDebug failed with exit code 1
  57. any suggestions can be helpful.thank you in advance.
  58. </details>
  59. # 答案1
  60. **得分**: 1
  61. 以下是已翻译的内容:
  62. **1-** 你可以在电脑上通过命令提示符运行Flutter Doctor
  63. 你可以通过以下方式打开命令提示符:
  64. 点击Windows开始按钮。
  65. 输入"command prompt"并按回车键。
  66. 一旦我们打开了命令提示符,你可以输入以下内容并按回车键:
  67. flutter doctor -v
  68. **2-** 然后,如果你使用的是Android Studio,请尝试重新启动你的IDE,并清除缓存。
  69. Android Studio中,你可以通过以下方式清除项目结构相关的信息:
  70. File > Invalidate Cache clears project structure related information (only) cached by Android studio.
  71. **3-** 如果这没有奏效,请尝试更改包的版本号。
  72. **4-** 最后,删除该包并用另一个包替换,可以从[github.com][1]或[pub.dev][2]获取另一个包。
  73. [1]: https://github.com
  74. [2]: https://pub.dev/
  75. 这就是我的解决方案,希望能够解决问题,祝一切顺利!
  76. <details>
  77. <summary>英文:</summary>
  78. There are many solutions here are they:
  79. **1-** You can run Flutter Doctor on a PC by using the command prompt.
  80. you can open the command prompt by:
  81. Clicking on the Windows Start button.
  82. Typing in command prompt and
  83. pressing Enter.
  84. Once we have the command prompt open, you can type the following and hit enter:
  85. flutter doctor -v
  86. **2-** Then try to restart your IDE if you had android studio go and delete cache from the
  87. File &gt; Invalidate Cache clears project structure related information (only) cached by Android studio.
  88. **3-** if it didn&#39;t work try changing the package version number
  89. **4-** lastly delete the package and replace it with another one either from [github.com][1] or [pub.dev][2]
  90. [1]: https://github.com
  91. [2]: https://pub.dev/
  92. Thats my solution I hope it works, all the best!
  93. </details>

huangapple
  • 本文由 发表于 2023年5月18日 12:35:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277762.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定