Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
659 views
in Technique[技术] by (71.8m points)

lint - How can I disable requiring types for collection literals in Dart?

I'm currently using the pedantic package for my dart/flutter linting.

My analysis_options.yaml look like

include: package:pedantic/analysis_options.yaml

linter:
  rules:
    always_specify_types: true
    omit_local_variable_types: false

I like having to specify types when I declare a variable line. But with this, I have to also specify the type on the created list/map.

The issues I have are the parts within **

const int number = 5;
const bool isTrue = false;
const String myName = 'Dan';
const List<int> numbers = **<int>**[1, 2, 3, 4];
const Map<String, int> ages = **<String, int>**{'Dan': 1};

It's redundent. How can I set my analysis_options.yaml to fix this.

Thanks!

question from:https://stackoverflow.com/questions/65853297/how-can-i-disable-requiring-types-for-collection-literals-in-dart

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...