flutter闭包和组件

和其他语言的闭包一样,都是定义在其他方法内部的方法(对象),通过闭包可以访问外部方法里面的局部变量,并且持有其状态。

1.常驻内存 2.不污染全局
闭包: 函数嵌套函数, 内部函数会调用外部函数的变量或参数, 变量或参数不会被系统回收(不会释放内存)
闭包的写法: 函数嵌套函数,并return 里面的函数,这样就形成了闭包。

void main(){
  var funcA = funcTest();
  funcA();
  funcA();
  funcA();
  funcA();
}
funcTest(){
 int a = 0;
 return (){
print(a++);
}//这个匿名函数就是一个闭包,打印结果0123
}

flutter 组件

  cupertino_icons: 0.1.2
  # 本地偏好设置 https://github.com/flutter/plugins/tree/master/packages/shared_preferences
  shared_preferences: 0.5.3+4
  # 图片缓存 https://github.com/renefloor/flutter_cached_network_image
  cached_network_image: 2.0.0
  # Flutter 常用工具库 https://github.com/Sky24n/flustars
  flustars: 0.2.6+1
  # 事件总线 https://github.com/marcojakob/dart-event-bus
  event_bus: 1.0.1
  # 路由管理 https://github.com/theyakka/fluro
  fluro: 1.6.3
  # Flutter 轮播图 https://github.com/best-flutter/flutter_swiper
  flutter_swiper: 1.1.6
  # Flutter 屏幕适配 https://github.com/OpenFlutter/flutter_screenutil
  flutter_screenutil: 0.6.0
  # 获取App信息 https://github.com/flutter/plugins/tree/master/packages/package_info
  package_info: 0.4.0+10
  # WebView插件 https://github.com/flutter/plugins/tree/master/packages/webview_flutter
  webview_flutter: 0.3.15+1
  # Flutter 城市列表,联系人列表,索引&悬停 https://github.com/flutterchina/azlistview
  azlistview: 0.1.2
  # Dart 汉字转拼音 https://github.com/flutterchina/lpinyin
  lpinyin: 1.0.7
  # 展示svg图片 https://github.com/dnfield/flutter_svg
  flutter_svg: 0.17.2
  # 图片浏览器 https://github.com/renancaraujo/photo_view
  photo_view: 0.9.2
  # 侧滑删除 https://github.com/letsar/flutter_slidable
  flutter_slidable: 0.5.4
  # 状态共享 https://github.com/rrousselGit/provider
  provider: 4.0.3
  # 控制屏幕旋转 https://github.com/sososdk/flutter_orientation
  orientation: 1.2.0

flutter数组操作

https://blog.csdn.net/sinat_17775997/article/details/106743822

你可能感兴趣的:(flutter闭包和组件)