1

I'm trying to build in production mode my flutter app for web, but I have my "main.dart" file not in the root lib directory, this cause to not be able to build my app for web, I have tried to point the path to where the "main.dart" file is, like:

flutter build web path/to/my/main/file/main.dart --release

But ended out with an error message like:

 Building with sound null safety 

Compiling lib/main.dart for the Web...                          
Target dart2js failed: Exception: .dart_tool/flutter_build/72a548668e340c281af31f7867ace19b/main.dart:8:8:
Error: Error when reading 'lib/main.dart': Error reading 'lib/main.dart'  (No such file or directory)
import 'package:the_movie_db_app/main.dart' as entrypoint;
       ^
.dart_tool/flutter_build/72a548668e340c281af31f7867ace19b/main.dart:13:14:
Error: Method not found: 'main'.
  entrypoint.main();
             ^^^^
Error: Compilation failed.

This command works when you try to build an APK, but not to build a flutter web app.

Can somebody please tell me how to solve this?

g14wx
  • 316
  • 1
  • 2
  • 7

1 Answers1

1

add -t before your main.dart path.

eg.

flutter build web -t lib/main-dev.dart