Dart 2 libraries in one lib folder causing type 'X' is not a subtype of type 'X' -


i have following problem: in application, have web , lib folders. lib folder supposed contain utility libraries. example:

lib/my_lib.dart

library my_lib; part 'src/person.dart'; 

lib/my_lib1.dart

library my_lib1; import 'my_lib.dart'; part 'src/other.dart'; 

in my_lib1, want use classes defined in my_lib

the classes follows:

lib/src/person.dart

part of my_lib; class person { } 

lib/src/other.dart

part of my_lib1; class other {   person p;   other(this.p) {    print(p);   } } 

now, in web/testpackage.dart

import 'package:testpackage/my_lib.dart'; import 'package:testpackage/my_lib1.dart';  void main() {   person p = new person();   other o = new other(p); } 

fails with:

exception: type 'person' not subtype of type 'person' of 'p'. other.other (package:testpackage/src/other.dart:7:14) 

how should structure project prevent that? libraries local app, , don't want develop them separately toy project.

problem in library my_lib publiclibrary , (and you, of course) can use elsewhere outside of lib directory.

in case must imported (becuase it's public library) package library.

to solve this problem must change source code.

from lib/my_lib1.dart

library my_lib1; import 'my_lib.dart'; part 'src/other.dart'; 

to lib/my_lib1.dart

library my_lib1; import 'package:testpackage/my_lib.dart'; part 'src/other.dart'; 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -