flutter 常备基础知识
- //数组包含某个值
listArr.contains(1)
- 溢出添加省略
Expanded(
flex: 1,
child: Text(
'$value',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: label == '状态:'
? ColorUtil.fromHex('#ff3300', 1)
: ColorUtil.fromHex('#2A313F', 1),
fontSize: 28.sp,
fontWeight: FontWeight.w500),
),
)
核心
maxLines: 2,
overflow: TextOverflow.ellipsis,
- // 过时API–
修改文件 build.gradle;主要注意版本号的搭配
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
- //遍历
_labels.map((e) => ColItem()).toList()) //ColItem 业务组件

这篇博客介绍了Flutter开发中的一些核心知识点,包括数组检查、文本溢出处理、Gradle版本更新以及遍历操作。同时展示了如何使用`contains()`方法检查数组是否包含特定值,通过设置`maxLines`和`TextOverflow.ellipsis`实现文本省略效果,以及更新Gradle配置避免使用过时API。此外,还提及了使用`map`函数进行列表遍历创建业务组件。
2826

被折叠的 条评论
为什么被折叠?



