【无标题】flutter笔记


#######################
页面跳转 弹出窗口  、传递参数、 
相同功能组件共通
退出程序  
ctrl+alt+L :格式化
########################################################################

#####
在输入文本框中TextFiled添加文本按钮TextButton:  用TextFormField

return TextFormField(
      //obscureText: _isObscure, // 是否显示文字
        decoration: InputDecoration(
            labelText: "検証コード",
            suffix: SizedBox(
              height: 20,
              child: TextButton(
                style: ButtonStyle(
                  padding: MaterialStateProperty.all(EdgeInsets.only(bottom: 0.0))
                ),
                onPressed: () {  },
                child: Text("検証コード送信"),
              ),
            )
        ));


####
FloatingActionButton:悬浮按钮

 FloatingActionButton(
            child: Icon(Icons.add),
            onPressed: c.increment,
        )

####
Get的两个状态管理器:
    简单状态管理器:GetBuilder
    响应式状态管理器:GetX  
####
Get的响应式编程: 当改变一个名称变量时 ,使用它的小组件都会自动刷新。

让它变得可观察,在末尾加上一个".obs"。
    var name = 'Jonatas Borges';
    var name = 'Jonatas Borges'.obs;

想要显示该值并在该值变化时更新页面,
    Obx(() => Text("${controller.name}"));

######################
//更改appBar菜单图标的颜色
        leading: Builder(builder: (BuildContext context) {
          return IconButton(
            color: Colors.black,
            icon: const Icon(Icons.menu),
            onPressed: () {   //打开抽屉页面
              Scaffold.of(context).openDrawer();
            },
           // tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
          );
        }),
#####################
轮播图
    Swiper(
      itemBuilder: (BuildContext context,int index){
        // 配置图片地址
        return new Image.network(productModel.headImages[index],fit: BoxFit.fill,);
      },
      // 配置图片数量
      itemCount: productModel.headImages.length ,
      // 底部分页器
      pagination: new SwiperPagination(),
      // 左右箭头
      control: new SwiperControl(),
      // 无限循环
      loop: true,
      // 自动轮播
      autoplay: true,
    )

Swiper(
            itemBuilder: (BuildContext context, int index) {
              return Image.asset(
                imageList[index],
                fit: BoxFit.fill,
              );
            },
            itemCount: 5,
            autoplay: true,
            pagination: new SwiperPagination(), //分页
            //control: new SwiperControl(),    //左右箭头
          ),
#############
文本自动折行,主轴空间不够用,次轴自动扩充。(column布局,写文本时间自动向下移)
加一个Flexible:
    Flexible(
                          child: Text(
                            "2021


###################
SDK版本高  增加了空安全: 在run->Edit Configurations中的Additional run args中加入如下:
flutter run --no-sound-null-safety

传参和url传参、
############
轮播图上加文本Text:
层叠样式Stack:
       child: Stack(
        children: [
          Swiper(
              
          ),
          Positioned(
            top: 230,
            left: 20,
            child: Container(
              child: Column(
               
     ),), ),
############
flutter Container中的Text为什么不能左对齐?
       由于TEXT组件的大小是自动包裹内容的,所以怎么设置都不会看到效果,因为没有
多余的空间去左对齐或右对齐等。但是这里Text组件放在Colum组件中,所以只需要对
Colum设置crossAxisAlignment: CrossAxisAlignment.start即可生效。

############
添加下拉上拉框加载:

late EasyRefreshController _controller;

  @override
  void initState() {
    super.initState();
    _controller = EasyRefreshController();
  }
###
EasyRefresh(
        header: ClassicalHeader(
          textColor: KColor.refreshTextColor,
          bgColor: Colors.white,
          infoColor:KColor.refreshTextColor,
          showInfo:false,
          noMoreText: '',
          refreshReadyText: KString.loading,
          refreshingText:KString.loading,
          refreshedText: KString.loaded,
        ),
        // 是否开启控制结束加载
        enableControlFinishLoad: true,
        // 控制器
        controller: _controller,
        // 自定义顶部上啦加载
        // footer: ClassicalFooter(
        //   bgColor: Colors.blue,
        //   // 是否显示提示信息
        //   showInfo: false,
        // ),
child: ListView(
          children: [
            shufflingFigure(), //轮播图
            informLabel(), //”通知“和”查看更多“按钮
            imageShowOne(), //卡片显示
            imageShowTwo(),
            imageShowThree(),
            // imageShowFour(),
          ],
        ),
###
 // onLoad: () async {
        //   await Future.delayed(const Duration(seconds: 1), () {
        //     _controller.finishLoad();
        //   });
        // },
        onRefresh: () async {
          await Future.delayed(const Duration(seconds: 1), () {
            _controller.finishLoad();
          });
#############


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值