Flutter && Dart

avatar
作者
猴君
阅读量:160

/// 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 命名规范:

  1. AaBb类规范
    首字母大写驼峰命名法,类似IsClassName,用于类的命名。
  2. aaBb类规范
    首字母小写驼峰,isParamName,用于常量和变量命名。
  3. 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);     }); } 

    广告一刻

    为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!