首页 > 其他 > 详细

Dart——库

时间:2020-10-21 09:41:34      阅读:31      评论:0      收藏:0      [点我收藏+]

1.分类

  • 自定义的库
    • import ""
  • 系统内置库
    • io,math,convert...
  • Pub包管理系统里面的库
    • 需要在自己的项目根目录新建一个pubspec.yaml
    • 在pubspec.yaml文件中配置名称、描述、依赖等信息
      • 技术分享图片

         注意:冒号后面需要有空格

    • 然后运行pub get (当前目录)获取包下载到本地
    • 项目中引入库: import "package:http/http.dart" as http
       

2.库的重命名(as关键字)

示例:

import ./Person.dart as P;

main(List<String> args) {
  P.Person p1 = new P.Person("xxx", 12);
}

 

3.部分导入(show关键字、hide关键字)

  • Person库:
    • fn1() {
        print("111");
      }
      
      fn2() {
        print("222");
      }
      
      fn3() {
        print("333");
      }
  • 引入Person库的文件
    • 1.show
    • import ./Person.dart show fn1;
      
      main(List<String> args) {
        fn1();
      }
      • 此时只会引入fn1()方法
    • 2.hide
    • import ./Person.dart hide fn1;

      此时会引入排除fn1以外的所有库

 

Dart——库

原文:https://www.cnblogs.com/codexlx/p/13849664.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!