void print(String name) {
var size = name.length;
하지만 사용하지 않는 변수에 대해서는 지금처럼 underscore 사용을 권장한다.
[1,2,3].map((_) => print('Hello'));
https://dart-lang.github.io/linter/lints/no_leading_underscores_for_local_identifiers.html
no_leading_underscores_for_local_identifiers
no_leading_underscores_for_local_identifiers Group: style Maturity: stable View all Lint Rules Using the Linter DON’T use a leading underscore for identifiers that aren't private. Dart uses a leading underscore in an identifier to mark members and top-le
dart-lang.github.io
2. depend_on_referenced_packages
패키지를 import 할 때 pubspec에 depencency를 추가해 주라고 한다.
기존에는 A 패키지를 사용하면 A패키지에서 사용하는 B패키지의 경우 따로 dependency를 추가하지 않고 사용했다면 이제는 B패키지도 동일하게 dependency를 추가해주어야 한다.
https://dart-lang.github.io/linter/lints/depend_on_referenced_packages.html
depend_on_referenced_packages
depend_on_referenced_packages Group: pub Maturity: stable View all Lint Rules Using the Linter DO Depend on referenced packages. When importing a package, add a dependency on it to your pubspec. Depending explicitly on packages that you reference ensures t
dart-lang.github.io
3. use_build_context_synchronously
BuildContext를 비동기 작업과 함께 사용하지 말라고 한다.
이유 : 나중에 (await 이후에) 사용할 BuildContext를 가지고 있는건 오류가 어디서 발생했는지 찾기 힘들기 때문
void onButtonTapped(BuildContext context) async {
await Future.delayed(const Duration(seconds: 1));
Navigator.of(context).pop();
GOOD!
void onButtonTapped() async {
await Future.delayed(const Duration(seconds: 1));
if (!mounted) return;
Navigator.of(context).pop();
use_build_context_synchronously
https://dart-lang.github.io/linter/lints/use_build_context_synchronously.html
use_build_context_synchronously
use_build_context_synchronously Group: errors Maturity: experimental View all Lint Rules Using the Linter DO NOT use BuildContext across asynchronous gaps. Storing BuildContext for later usage can easily lead to difficult to diagnose crashes. Asynchronous
dart-lang.github.io