# flutter 组件

# Text 样式

这里的 heigth * fontSize 就是行高

const textStyle = TextStyle(
  color: Color.fromRGBO(80, 82, 87, 1),
  fontSize: 12.0,
  height: 1.4,
);
Text(
  '摩配配是专为零售店主,提供优质货源的进货平台\n认证店铺信息,享受批发价格专属服务',
  style: textStyle,
  textAlign: TextAlign.center,
)

# 按钮

# 宽度 100% 的按钮

<!-- 圆角 -->
ShapeBorder shape = const RoundedRectangleBorder(
  borderRadius: BorderRadius.all(
    Radius.circular(3),
  ),
);
MaterialButton(
  shape: shape,
  height: 50,
  minWidth: double.infinity,
  elevation: 0.0,
  child: Text(
    "去认证",
    style: TextStyle(
        color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16.0),
  ),
  onPressed: () {},
  color: Color.fromRGBO(227, 75, 64, 1),
)

# TextField 样式

TextField(
    autofocus: true,
    style: TextStyle(
        color: Color.fromRGBO(18, 18, 18, 1),
        fontSize: 16,
        fontWeight: FontWeight.w500),
    decoration: InputDecoration(
        contentPadding:
            EdgeInsets.symmetric(vertical: 18),
        border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(5),
            borderSide: BorderSide.none),
        filled: true,
        fillColor: Color.fromRGBO(245, 247, 247, 1),
        hintText: "请输入手机号码",
        prefixIcon: Image(
            image: AssetImage(
                "assets/images/login/account.png"))))

# 模态框

<!-- 显示 -->
showMySimpleDialog(context);

void showMySimpleDialog(BuildContext context) {
  var tipsTextStyle = TextStyle(
    fontSize: 14,
    color: Color.fromRGBO(74, 74, 74, 1),
  );
  showDialog(
      context: context,
      builder: (context) {
        return new SimpleDialog(
          contentPadding: EdgeInsets.only(top: 35, bottom: 45),
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(5),
          ),
          children: <Widget>[
            Center(
                child: Image(
                    image: AssetImage("assets/images/login/add_user.png"))),
            SizedBox(height: 24),
            Text(
              '您已成功注册账号',
              textAlign: TextAlign.center,
              style: tipsTextStyle,
            ),
            SizedBox(height: 6),
            Text(
              '将自动返回登录页面',
              textAlign: TextAlign.center,
              style: tipsTextStyle,
            ),
          ],
        );
      });
}

# 停用方法

首次不会执行(页面显示隐藏判断)


bool isVisible = true;

@override
void deactivate() {
  isVisible = !isVisible;
  print('isVisible');
  print(isVisible);
  if (isVisible) {
    //onResume
  } else {
    //onStop
  }
  super.deactivate();
}

# 生成列表


List<Widget> licenseList = List.generate(data.licenseList.length, (i) {
  return FractionallySizedBox(
    widthFactor: 0.45,
    child: MyCachedNetworkImage(
      data.licenseList[i].path,
      size: 155,
    ),
  );
});

# 物理返回钩子

WillPopScope(
  onWillPop: () async {
    //do something
    return true;
  },
  child:Text("12"),
)
lastUpdate: 5/26/2020, 7:17:09 AM