Upgrading to Dart2/Angular5 Error importing template.dart


I am upgrading my dart/angular project to dart 2.x/angular 5.x. The sample in phpstorm works, but when I build my project, then I am getting following error:

[SEVERE] build_modules|modules on lib/app_component.template.dart:

Bad state: No element
[SEVERE] build_web_compilers|entrypoint on web/main.dart:
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).

Please check the following imports:

`import 'package:mfgapp/app_component.template.dart' as ng;` from mfgapp|web/main.template.dart at 8:1
`import 'package:mfgapp/app_component.template.dart' as ng;` from mfgapp|web/main.dart at 1:1

I migrated the project with the guidlines, and dart analysis does not show any errors

Here are some of my files:

import 'package:angular/angular.dart';
import 'package:mfgapp/app_component.template.dart' as ng;

void main() {


import 'package:angular/angular.dart';

  selector: 'mfgapp',
  styleUrls:  ['package:angular_components/src/components/app_layout/layout.scss.css', 'layout.css', 'app_component.css'],
  templateUrl: 'app_component.html',

class AppComponent {



name: mfgapp
description: A web app that uses AngularDart Components

  sdk: '>=2.0.0-dev.68.0 <3.0.0'

  angular: ^5.0.0-beta
  angular_components: ^0.9.0-beta

  angular_test: ^2.0.0-beta
  build_runner: ^0.9.0
  build_test: ^0.10.2
  build_web_compilers: ^0.4.0
  test: ^1.0.0

I reduced my code to indicate the error, but there is no change. Even if I delete the import statement, I am getting error that app_component.template.dart as ref1 cannot be imported.


The same issue for me. Cleaning the project fixed the issue.

pub cache repair

Answered By – Bas E

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *