Flutter && Dart

手机游戏开发者 2024-9-18 18:07:11 83 0 来自 中国
/// Dart 弱范例(var、object、dynamic)
/// Dart中没有=== 运算符。
/// 简介写法:
/// 三元运算符??: t ?? 'test'是t!=null ? t : 'test'的缩写。
/// 级联利用符(依次举行调用),允许对同一对象或函数举行一系列利用,testObj.add('t')..delete('d')..show();
类: 定名构造函数class Dog{    String color;    Dog.red(){this.color='red';}    Dog.black(){this.color='black';}}void main(List<String> args) {    Dog redDog = new Dog.red();    print(redDog.color);    Dog blackDog = new Dog.black();    print(blackDog.color);}Flutter 定名规范:

  • AaBb类规范
    首字母大写驼峰定名法,类似IsClassName,用于类的定名。
  • aaBb类规范
    首字母小写驼峰,isParamName,用于常量和变量定名。
  • aa_bb类规范
    小写字母下换线毗连法,如is_file_name,用于文件和文件夹定名。
表明文档天生,在As的Terminal中打开下令行窗口,运行下令 dartdoc,
会在当前目次中天生doc的文件夹,内里有天生的html文档。
组件:
ClipRRect:圆角组件,让子组件有本相变焦。
Container:布局组件,容器组件。类似前端的body。
Expanded:按比例拉伸,
Padding:添补空缺地域,
ListView下拉革新组件:RefreshIndicator,onRefresh方法中触发革新变乱。上拉加载更多。_scrollControllser.addListener((){    if(!hasMore) return;    if(!isLoading && _scrollControllser.position.pixels         >= _scrollControllser.position.maxScrollExtent) {        isLoading = true;        loadMoreData();    }});/// 加载更多。void loadMoreData() {    StructApiContentListRetInfo retInfo = ApiContentInndex().getRecomList(lastId);    List<StructContentDetail> newList = retInfo.data;    setState((){        isLoading=false;        hasMore = retInfo.hasMore;        contentList.addAll(newList);    });}
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-10-18 16:50, Processed in 0.162467 second(s), 32 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表