flutter学习问题合集

1、Prefer using lowerCamelCase for constant names.

(1)代码上面添加一行注释:// ignore: constant_identifier_names

(2)项目根目录增加一个配置文件:analysis_options.yaml,并添加规则。

linter:

  rules:

    constant_identifier_names: false

2、 Use interpolation to compose strings and values.

改变字符串拼接方式。

print('hi_net:' + log.toString());

改为: 

print('hi_net:${log.toString()}');

3、Unnecessary braces in a string interpolation. Try removing the braces.

 改变字符串拼接方式。

print("aaa---${result}");

改为: 

print("aaa---$result");

4、Don't invoke 'print' in production code.Try using a logging framework.

print("aaa---$result");

 改为: 

import 'package:flutter/material.dart';
//或者
import 'package:flutter/cupertino.dart';

debugPrint("aaa---$result");

参考:dart官网-avoid_print介绍icon-default.png?t=N7T8https://dart.dev/tools/linter-rules/avoid_print#:~:text=Details DO avoid print calls in production code.,surround print calls with a check for kDebugMode

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bug菌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值