Dart: pub build minified dart.js missing

Issue

I am very new to Dart so bear with me. I completed the sample pirate badge project and did Pub Build – Minified as instructed. The generated build folder does not contain the packages/browser/dart.js and priatebadge.dart files that are referenced by piratebadge.html.

When I view in the browser there are errors related to those missing files. If I change the html page to reference the generated piratebadge.dart.js file it works.

Is this manual change something that has to be done with dart projects? or am I missing something in the build process?

Solution

At first, ensure you build in release mode. (default if you run pub build from command line.

I haven’t checked for a while but I assume there is still this Dart script tag which was introduced when it was still planned to integrate Dart into Chrome. This will hopefully fixed soon. In the meantime you can fix this manually or use https://pub.dartlang.org/packages/dart_to_js_script_rewriter to automate this step.

Answered By – Günter Zöchbauer

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.