常用快捷键:
展开/关闭代码块:
command + .
跳转到 下/上 一个光标位置:alt + command + →/←
(右/左箭头)
去除无用的import头文件:ctrl +alt + o
全局搜索:command + shift + f
快速更换/添加/移除widget:鼠标点到要操作的widget上,按下alt + 回车
一键复制:command + d
flutter代码格式化:Mac:command + alt + f
Windows:Ctrl+Alt+L
颜色的各种写法
Color c1 = Color(0xFF3CAAFA);
Color c2 = Color.fromRGBO(60, 170, 250, 0.2);
Color c3 = Color.fromARGB(255, 60, 170, 250);
Color c5 = Colors.blue;
Color c6 = Colors.red[600];
项目不能新建directory的解决办法
解决文件夹中嵌套文件夹呈现 xxx.yyy的格式(按下图取消勾选):

flutter 控件随着键盘弹出自适应上下移动 防止遮挡
flutter项目拉下来如果有主模块有分模块 需要分别同时点一下这个

flutter中如何导入插件 .jar包(
image.png
例如MVP模板 StlIdePlugin)


flutter 如何创建使用导入的MVP模板
在Android studio顶部菜单栏上 选中STL 打开编辑栏


模板说明

flutter如何引入脚本(多语言 辅助R文件)




如何跑脚本:

项目中如何使用:

附上脚本内容

flutter 多语言
easy_localization
APP账号密码登录流程:

APP自动登录流程

flutter 自定义底部切圆角弹框
void _clickMoreBtn() {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent, // 重点!!!
builder: (BuildContext context) {
return Container(
height: 462.h,
width: double.infinity,
child: Center(child: OtherLoginWaySheet()),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.w),
topRight: Radius.circular(50.w),
),
),
);
},
);
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:libcommon/res/colors.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:libcommon/generated/codegen_r_loader.g.dart';
import 'package:stl_easy_localization/stl_easy_localization.dart';
class OtherLoginWaySheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Column(children: [
Padding(
padding: EdgeInsets.only(top: 80.w, bottom: 40.h),
child: InkWell(
onTap: () {
print("点击QQ登录");
},
child: Container(
width: 240.w,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 56.w,
height: 56.w,
child: SvgPicture.asset(
"assets/svg/fxchat_login_ic_login_qq.svg",
package: 'fxchat_login',
),
),
SizedBox(width: 20.w),
Text(R.fxchat_login_qq_login).tr(),
],
),
),
),
),
Padding(
padding: EdgeInsets.only(top: 30.0.h, bottom: 60.h),
child: InkWell(
onTap: () {
print("点击微博登录");
},
child: Container(
width: 240.w,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 56.w,
height: 56.w,
child: SvgPicture.asset(
"assets/svg/fxchat_login_ic_login_weibo.svg",
package: 'fxchat_login',
),
),
SizedBox(width: 20.w),
Text(R.fxchat_login_weibo_login).tr(),
],
),
),
),
),
SizedBox(
width: 654.w,
height: 96.h,
child: FlatButton(
color: ColorsUtil.hexToColor("#eff1f4"),
onPressed: () {
Navigator.of(context).pop();
},
child: Text(
R.fxchat_login_cancel.tr(),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: ColorsUtil.hexToColor("#e61e222b")),
),
),
),
]),
);
}
}
使用Android studio 进行版本控制和冲突解决等



创建按钮装不下字的时候 需要新添加一行
visualDensity: VisualDensity(horizontal: -4, vertical: -4),
Container(
width: 120.w,
height: 56.h,
child: FlatButton(
visualDensity: VisualDensity(horizontal: -4, vertical: -4),
color: Colors.yellow,
disabledColor: Colors.black12,
textColor: Colors.red,
disabledTextColor: Colors.grey,
onPressed: () {},
child: Text(
"同意",
style: TextStyle(fontSize: 14),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(28.h)),
),
)
flutter 退出到指定页面
STLRouter.of().navigator.pushNamedAndRemoveUntil(
RouterFXChatMine.ROUTER_INNER_MINE_PAGE, (route) => route == null);
使用Android studio 进行Git版本控制
用Android studio打开你的本地项目,






Git版本控制——保存修改到本地

flutter 清除应用库的缓存

flutter 清除缓存
flutter clean
image.png
汇聊拉完代码需要在终端输入下面命令 batchUpgrade.sh是自己写的
作用是快速 pub upgrade 各个模块
./batchUpgrade.sh


对应的文件内容

// batchUpgrade.sh
#!/bin/bash
for subDir in `ls`
do
subPath="$(pwd)/$subDir"
if [ -d "$subPath" ]
then
#判断文件夹中是否包含 yaml文件
needUpgrade=false
for subFile in `ls $subPath`
do
if [ "${subFile##*.}"x = "yaml"x ]
then
needUpgrade=true
fi
done
if [ $needUpgrade = true ]
then
cd $subPath
flutter pub upgrade
cd ..
fi
fi
done
#根目录下执行
flutter pub upgrade
网友评论