Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Dart is giving error : The getter 'injector$Injector' isn't defined for the class 'self'

I am just trying Routing in Angular Dart. I was following this https://webdev.dartlang.org/angular/guide/router/1 guide but I am getting an error.

This line is giving error final InjectorFactory injector = self.injector$Injector; and the error is The getter 'injector$Injector' isn't defined for the class 'self.

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

import 'main.template.dart' as self;

const useHashLS = false;
@GenerateInjector(routerProvidersHash)

final InjectorFactory injector = self.injector$Injector;
// The getter 'injector$Injector' isn't defined for the class 'self' 

void main() {
  runApp(ng.AppComponentNgFactory, createInjector: injector);
}
like image 486
nitishk72 Avatar asked Jan 22 '26 18:01

nitishk72


2 Answers

I was having the same problem, as it complete with no errors, I just added the following on analysis_options.yaml to ignore the error.

analyzer:
  errors:
    undefined_getter: ignore

Answer by https://stackoverflow.com/a/53304768/2997534

like image 100
user2997534 Avatar answered Jan 25 '26 17:01

user2997534


I stumbled upon a workaround without ignoring the analyzer:

import 'main.template.dart' show injector$Injector;

@GenerateInjector(routerProvidersHash)
final InjectorFactory injector = injector$Injector;

Showing the injector$Injector seems to fix the error.

like image 35
hola Avatar answered Jan 25 '26 17:01

hola



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!