Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter web throws error on same project but different laptop

So I just won a new laptop in a competition and now I am having some trouble migrating my flutter projects. I have set up the editor and migrated the important files in the code, i.e the lib, image, font, pubspec.yaml and web. But this app is now throwing the following error

Launching lib\main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
ERROR - 2020-12-29 13:08:07.845202
GET /main_module.bootstrap.js
Error thrown by handler.
AbsoluteImportUriError: 'file:///C:/FlutterProjects/xspectre/lib/help/Auth.dart'
package:dwds/src/debugging/metadata/provider.dart 154:9   MetadataProvider._addMetadata
package:dwds/src/debugging/metadata/provider.dart 133:15  MetadataProvider._initialize.<fn>

I thought it may be a problem with my flutter but it runs the default flutter app without problem.
I also tried deleting the file but the problem just shifts to another file. I can safely say that this a is a problem with the help folder which provides me essential tools such as the auth service. What should I do? I will provide any code neccesary. You can find the entire code here

like image 855
Siddharth Agrawal Avatar asked Dec 29 '20 07:12

Siddharth Agrawal


People also ask

Is flutter Web in stable?

Is the web version of Flutter ready for production? Flutter's web support is now available on the stable channel, offering an app-centric framework that builds on the power of the modern web platform. Find out more details about Flutter's production quality support for the web.

Can flutter run on Web browser?

Command line The flutter run command launches the application using the development compiler in a Chrome browser. Warning: Hot reload is not supported in a web browser Currently, Flutter supports hot restart, but not hot reload in a web browser.

How are errors handled in flutter?

By default, in debug mode this shows an error message in red, and in release mode this shows a gray background. When errors occur without a Flutter callback on the call stack, they are handled by the Zone where they occur.

What happens if invokemethod throws an error in flutter?

If invokeMethod throws an error, it won’t be forwarded to FlutterError.onError . Instead, it’s forwarded to the Zone where runApp was run. To catch such an error, use runZonedGuarded.

How does flutter layout work?

“ To perform layout, Flutter walks the render tree in a depth-first traversal and passes down size constraints from parent to child… Children respond by passing up a size to their parent object within the constraints the parent established. ” – Flutter architectural overview

How to fix flutter DART file is not working?

Step 1: Look at the top of all your .dart files, more precisely at every single import. You will have to change everything starting with: import 'file:///C:/... If still issues, then make sure you looked at all your files to ensure you did not miss other wrong import ... also, you can run flutter clean then run a Pub Get


1 Answers

The Error:

The error is happening because when importing your new project, some imports in your .dart files are now using absolute paths instead of relative paths. In your case, this is happening at least in one .dart file that is calling your Auth.dart.

Sloution:

Step 1: Look at the top of all your .dart files, more precisely at every single import. You will have to change everything starting with:

import 'file:///C:/...

by

import 'package:... and add the name of your app

Step 2: Rerun your project and everything should work now

If still issues, then make sure you looked at all your files to ensure you did not miss other wrong import... also, you can run flutter clean then run a Pub Get

(thanks to melwinlobo18)

Please mark the answer if this was useful ;0)

like image 97
Canada2000 Avatar answered Oct 13 '22 07:10

Canada2000