Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when reading 'lib/generated_plugin_registrant.dart' in Flutter

I'm new to flutter development. When I try to create my application in local using flutter is working fine. But if I try to import other repo after resolving the dependencies, still it's not working.

What i did:

  1. I'm executing the application in Chrome, not in devices.
  2. I have tried in both the Master and Beta channels.
  3. I did Flutter clean, Flutter pub get and delete .vscode still issue is not resolved.

Error Log:

--initialize-from-dill build\cache.dill.track.dill --platform
file:///C:/Users/user/Documents/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk.dill
[ +197 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+1275 ms]
                    Compiler message:
[   +1 ms] org-dartlang-app:/web_entrypoint.dart:7:8: Error: Error when reading 'lib/generated_plugin_registrant.dart':
The system cannot find the file specified.
[        ] import 'package:neucalcu/generated_plugin_registrant.dart';
[        ]        ^
[+5310 ms] org-dartlang-app:/web_entrypoint.dart:10:3: Error: Method not found: 'registerPlugins'.
[   +1 ms]   registerPlugins(webPluginRegistry);
[        ]   ^^^^^^^^^^^^^^^
[+33861 ms] Syncing files to device Chrome... (completed in 40,952ms, longer than expected)
[   +1 ms] Synced 0.0MB.
[   +1 ms] Failed to compile application.
[   +4 ms] "flutter run" took 66,431ms.

doctor log:

[√] Flutter (Channel beta, 1.19.0-4.2.pre, on Microsoft Windows [Version 10.0.14393], locale en-US)
    • Flutter version 1.19.0-4.2.pre at C:\Users\user\Documents\flutter
    • Framework revision 9b9b543d92 (4 days ago), 2020-06-22 12:19:28 -0700
    • Engine revision 9a28c3bcf4
    • Dart version 2.9.0 (build 2.9.0-14.1.beta)


[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at C:\Users\user\AppData\Local\Android\Sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: C:\Users\user\Documents\Android\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.0)
    • Android Studio at C:\Users\user\Documents\Android
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.46.1)
    • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.11.0

[√] Connected device (2 available)
    • Web Server • web-server • web-javascript • Flutter Tools
    • Chrome     • chrome     • web-javascript • Google Chrome 83.0.4103.116

• No issues found!

pubspec.yml

name: Calendar app
description: A new Flutter application.

publish_to: 'none'

version: 1.2.2+8

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.3
  flutter_circle_color_picker: ^0.2.0
  google_fonts: ^1.1.0
  hive: ^1.4.1+1
  hive_flutter: ^0.3.0+2
  line_awesome_icons: ^1.0.4+2
  math_expressions: ^2.0.0
  provider: ^4.1.3
  url_launcher: ^5.4.10

dev_dependencies:
  flutter_test:
    sdk: flutter
  hive_generator: ^0.7.0+2
  build_runner: ^1.10.0

dependency_overrides:
  dartx: ^0.4.0
  path: ^1.7.0

flutter:
  uses-material-design: true

  assets:
    - assets/logo.png

REF - https://github.com/flutter/flutter/issues/48361

like image 237
RED.Skull Avatar asked Jun 26 '20 09:06

RED.Skull


People also ask

What is Generated_plugin_registrant Dart?

generated_plugin_registrant. dart is an automatically generated file that is required to compile your Flutter project as a web application: This file generated_plugin_registrant. dart exists only to support the web. It exists if Flutter is web-enabled and there is at least one package that has asked for it.

What is GeneratedPluginRegistrant?

The GeneratedPluginRegistrant is automatically generated by a FlutterApplication in order to register plugins defined in your Flutter App's pubspec.yaml file.

What is main dart in Flutter?

Once you have created your project, you will see the “lib” folder where the “main. dart” file is located. main.dart. Most importantly, once you have created a project and developed the application, Flutter expects the “main. dart” file to exist.


1 Answers

"Error when reading 'lib/generated_plugin_registrant.dart" Happens when you run your flutter app in chrome device after master channel upgrade without giving web support .

Solution : Give web support to your flutter by hitting below command.

flutter create .

This will create necessary support files for web app. further instruction will come in screen.

Reference last statement of this article

https://flutter.dev/docs/get-started/web

like image 77
Manas Ranjan Mohanty Avatar answered Oct 24 '22 14:10

Manas Ranjan Mohanty