在flutter.io/get-started/codelab上发现的此片段上运行dartanalyzer会产生以下错误:
$ dartanalyzer lib/main.dart
Analyzing lib/main.dart...
error • The function 'MyApp' isn't defined at lib/main.dart:3:23 • undefined_function
error • 'MaterialApp' isn't a function at lib/main.dart:8:12 • invocation_of_non_function
error • 'Scaffold' isn't a function at lib/main.dart:10:13 • invocation_of_non_function
error • 'AppBar' isn't a function at lib/main.dart:11:17 • invocation_of_non_function
error • 'Text' isn't a function at lib/main.dart:12:18 • invocation_of_non_function
error • 'Center' isn't a function at lib/main.dart:14:15 • invocation_of_non_function
error • 'Text' isn't a function at lib/main.dart:15:18 • invocation_of_non_function
7 errors found.
$ dartanalyzer --version
dartanalyzer version 1.24.3
我该怎么做才能使分析仪正确运行?
答案 0 :(得分:2)
对于Flutter项目,而不是运行dartanalyzer
,应运行flutter analyze
。 Flutter附带了它自己的SDK,因此常规的dart分析器如果没有一些额外的配置(该命令提供的配置)就无法工作。