| |
|
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
| -> 移动开发 -> flutter代码规范配置 -> 正文阅读 |
|
|
[移动开发]flutter代码规范配置 |
|
背景 学习新的语法时,经常会习惯性带上以前使用的语法风格,导致新的语法不规范,为了能够编写出更加健壮的flutter代码,谷歌在SDK2.3.0开始出了flutter代码规范检查,方便我们在开发时及时发现我们代码问题。如果你创建项目时使用的SDK是2.3.0以上默认是配置代码规范的,我现在说下2.3.0以下怎么配置代码规范。 配置1:检查你的SDK是否高于2.3.0,没有就更新高版本sdk
配置2:在项目根目录创建analysis_options.yaml文件 (文件内容如下) # This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
配置3:配置依赖?是在dev_dependencies配置(注意pub get)
效果:
flutter_lints库有两个文件
删除规则同样也可以删除默认的规则中的某些规则,或者让他不起效,只需要在analysis_option.yaml文件中的rules中,增加规则名称,并设置为false?(注意pub get) 在analysis_options文件
增加规则 只需要在analysis_option.yaml文件中的rules中,增加规则名称,并设置为true?(注意pub get)
?规格文档 https://dart-lang.github.io/linter/lints/index.html 参考 官网:https://pub.flutter-io.cn/documentation/flutter_lints/latest/ ? ? ? ? ???https://dart-lang.github.io/linter/lints/index.html |
|
|
| 移动开发 最新文章 |
| Vue3装载axios和element-ui |
| android adb cmd |
| 【xcode】Xcode常用快捷键与技巧 |
| Android开发中的线程池使用 |
| Java 和 Android 的 Base64 |
| Android 测试文字编码格式 |
| 微信小程序支付 |
| 安卓权限记录 |
| 知乎之自动养号 |
| 【Android Jetpack】DataStore |
|
|
| 上一篇文章 下一篇文章 查看所有文章 |
|
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
| 360图书馆 购物 三丰科技 阅读网 日历 万年历 2025年11日历 | -2025/11/21 9:55:55- |
|
| 网站联系: qq:121756557 email:121756557@qq.com IT数码 |