dart import and part of directives in same file

前端 未结 1 1547
北海茫月
北海茫月 2021-01-06 21:43

I\'m writing a dart file:

import \'something.dart\'

part of my_lib;

class A{
    //...
}

I have tried this with the import a

相关标签:
1条回答
  • 2021-01-06 22:19

    All your imports should go in the file that defines the library.

    Library:

    library my_lib;
    
    import 'something.dart';
    
    part 'a.dart';
    
    class MyLib {
      //...
    }
    

    a.dart

    part of my_lib;
    
    class A {
      //...
    }
    

    Since a.dart is part of my_lib it will have access to any files that my_lib imports.

    0 讨论(0)
提交回复
热议问题