首页 > 解决方案 > 向应用程序添加 Web 支持时出现颤振错误

问题描述

我刚刚发现我可以在不编写外部代码的情况下将我的 Flutter 应用程序更改为网站。我决定在我的应用程序上测试它,但我收到了这个错误,我不知道如何修复它。我按照“网站”上的步骤操作,但仍然出现错误。我的堆栈跟踪是:-

This application is not configured to build on the web.
To add web support to a project, run `flutter create .`.
Launching lib\main.dart on Web Server in debug mode...
Syncing files to device Web Server...
org-dartlang-app:/web_entrypoint.dart:8:8: Error: Error when reading 'lib/generated_plugin_registrant.dart': The system cannot find the file specified.

import 'package:discountapp/generated_plugin_registrant.dart';
       ^
org-dartlang-app:/web_entrypoint.dart:11:3: Error: Method not found: 'registerPlugins'.
  registerPlugins(webPluginRegistry);
  ^^^^^^^^^^^^^^^
Failed to compile application.

我运行颤振创建。它说

C:\Users\Hemant\AndroidStudioProjects\discountapp\ios>flutter create .
Recreating project ....
Wrote 3 files.

All done!
[√] Flutter: is fully installed. (Channel beta, 1.20.0-7.2.pre, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
[√] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 29.0.3)
[√] Chrome - develop for the web: is fully installed.
[√] Android Studio: is fully installed. (version 4.0)
[√] Connected device: is fully installed. (3 available)

In order to run your application, type:

  $ cd .
  $ flutter run

Your application code is in .\lib\main.dart.


C:\Users\Hemant\AndroidStudioProjects\discountapp\ios>flutter create .
Recreating project ....
Wrote 3 files.

All done!
[√] Flutter: is fully installed. (Channel beta, 1.20.0-7.2.pre, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
[√] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 29.0.3)
[√] Chrome - develop for the web: is fully installed.
[√] Android Studio: is fully installed. (version 4.0)
[√] Connected device: is fully installed. (3 available)

In order to run your application, type:

  $ cd .
  $ flutter run

Your application code is in .\lib\main.dart.

运行 flutter run 将在我的手机上运行它。我将提供所需的任何代码。请帮忙

标签: flutterflutter-web

解决方案


您必须flutter create .在应用程序的根文件夹中运行,而不是在ios子文件夹中。


推荐阅读