https://www.dartcn.com/
使用vscode编辑器,可先安装Dart 、Flutter 、Flutter widget snippets等扩展插件
3、flutter沉浸式状态栏/底部tabbar
========================
flutter中如何实现顶部全背景沉浸式透明状态栏(去掉状态栏黑色半透明背景),去掉右上角banner
4、flutter图标组件/IconData自定义封装组件
=============================
-
1、使用系统图标组件: Icon(Icons.search)
-
2、使用IconData方式: Icon(IconData(0xe60e, fontFamily:‘iconfont’), size:24.0)
使用第二种方式需要先下载阿里图标库字体文件,然后在pubspec.yaml中引入字体
class GStyle {
// __ 自定义图标
static iconfont(int codePoint, {double size = 16.0, Color color}) {
return Icon(
IconData(codePoint, fontFamily: ‘iconfont’, matchTextDirection: true),
size: size,
color: color,
);
}
}
调用非常简单,可自定义颜色、字体大小;GStyle.iconfont(0xe635, color: Colors.orange, size: 17.0)
5、flutter实现badge红点/圆点提示
=======================
如上图:在flutter中没有圆点提示组件,需要自己封装实现;
class GStyle {
// 消息红点
static badge(int count, {Color color = Colors.red, bool isdot = false, double height = 18.0, double width = 18.0}) {
final _num = count > 99 ? ‘···’ : count;
return Container(
alignment: Alignment.center, height: !isdot ? height : height/2, width: !isdot ? width : width/2,
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(100.0)),
child: !isdot ? Text(‘$_num’, style: TextStyle(color: Colors.white, fontSize: 12.0)) : null
);
}
}
支持自定义红点大小、颜色,默认数字超过99就…显示;GStyle.badge(0, isdot:true)GStyle.badge(13)GStyle.badge(29, color: Colors.orange, height: 15.0, width: 15.0)
6、flutter长按自定义弹窗
================
- 在flutter中如何实现长按,并在长按位置弹出菜单,类似微信消息长按弹窗效果;
通过InkWell组件提供的onTapDown事件获取坐标点实现
InkWell(
splashColor: Colors.grey[200],
child: Container(…),
onTapDown: (TapDownDetails details) {
_globalPositionX = details.globalPosition.dx;
_globalPositionY = details.globalPosition.dy;
},
onLongPress: () {
_showPopupMenu(context);
},
),
// 长按弹窗
double _globalPositionX = 0.0; //长按位置的横坐标
double _globalPositionY = 0.0; //长按位置的纵坐标
void _showPopupMenu(BuildContext context) {
// 确定点击位置在左侧还是右侧
bool isLeft = _globalPositionX > MediaQuery.of(context).size.width/2 ? false : true;
// 确定点击位置在上半屏幕还是下半屏幕
bool isTop = _globalPositionY > MediaQuery.of(context).size.height/2 ? false : true;
showDialog(
context: context,
builder: (context) {
return Stack(
children: [
Positioned(
top: isTop ? _globalPositionY : _globalPositionY - 200.0,
left: isLeft ? _globalPositionX : _globalPositionX - 120.0,
width: 120.0,
child: Material(
…
),
)
],
);
}
);
}
- flutter如何实现去掉AlertDialog弹窗大小限制?
可通过SizedBox和无限制容器UnconstrainedBox组件实现
void _showCardPopup(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return UnconstrainedBox(
constrainedAxis: Axis.vertical,
child: SizedBox(
width: 260,
child: AlertDialog(
content: Container(
…
),
elevation: 0,
contentPadding: EdgeInsets.symmetric(horizontal: 10.0, vertical: 20.0),
),
),
);
}
);
}
7、flutter登录/注册表单|本地存储
=====================
flutter提供了两个文本框组件:TextField 和 TextFormField本文是使用TextField实现,并在文本框后添加清空文本框/密码查看图标
TextField(
keyboardType: TextInputType.phone,
controller: TextEditingController.fromValue(TextEditingValue(
text: formObj[‘tel’],
selection: new TextSelection.fromPosition(TextPosition(affinity: TextAffinity.downstream, offset: formObj[‘tel’].length))
)),
decoration: InputDecoration(
hintText: “请输入手机号”,
isDense: true,
hintStyle: TextStyle(fontSize: 14.0),
suffixIcon: Visibility(
visible: formObj[‘tel’].isNotEmpty,
child: InkWell(
child: GStyle.iconfont(0xe69f, color: Colors.grey, size: 14.0), onTap: () {
setState(() { formObj[‘tel’] = ‘’; });
}
),
),
border: OutlineInputBorder(borderSide: BorderSide.none)
),
onChanged: (val) {
setState(() { formObj[‘tel’] = val; });
},
)
TextField(
decoration: InputDecoration(
hintText: “请输入密码”,
isDense: true,
hintStyle: TextStyle(fontSize: 14.0),
suffixIcon: InkWell(
child: Icon(formObj[‘isObscureText’] ? Icons.visibility_off : Icons.visibility, color: Colors.grey, size: 14.0),
onTap: () {
setState(() {
formObj[‘isObscureText’] = !formObj[‘isObscureText’];
});
},
),
border: OutlineInputBorder(borderSide: BorderSide.none)
),
obscureText: formObj[‘isObscureText’],
onChanged: (val) {
setState(() { formObj[‘pwd’] = val; });
},
)
验证消息提示则是使用flutter提供的SnackBar实现
// SnackBar提示
final _scaffoldkey = new GlobalKey();
void _snackbar(String title, {Color color}) {
_scaffoldkey.currentState.showSnackBar(SnackBar(
backgroundColor: color ?? Colors.redAccent,
content: Text(title),
duration: Duration(seconds: 1),
));
}
另外本地存储使用的是shared\_preferences,至于如何使用可参看https://pub.flutter-io.cn/packages/shared_preferences
void handleSubmit() async {
if(formObj[‘tel’] == ‘’) {
_snackbar(‘手机号不能为空’);
}else if(!Util.checkTel(formObj[‘tel’])) {
_snackbar(‘手机号格式有误’);
}else if(formObj[‘pwd’] == ‘’) {
_snackbar(‘密码不能为空’);
}else {
// …接口数据
// 设置存储信息
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip204888 (备注Android)
重要知识点
下面是有几位Android行业大佬对应上方技术点整理的一些进阶资料。
高级进阶篇——高级UI,自定义View(部分展示)
UI这块知识是现今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!
- 面试题部分合集
一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
点
下面是有几位Android行业大佬对应上方技术点整理的一些进阶资料。
[外链图片转存中…(img-X9eU8RD0-1712785427064)]
高级进阶篇——高级UI,自定义View(部分展示)
UI这块知识是现今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!
[外链图片转存中…(img-QSM8GT5f-1712785427064)]
- 面试题部分合集
[外链图片转存中…(img-o5dZvn8O-1712785427065)]
一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[外链图片转存中…(img-QkME6POT-1712785427065)]