我正在尝试使用flutter create app_name
来测试抖动,并使用Android Studio和VS Code我未定义runApp
上的错误,并且在Flutter库中的任何地方我都看不到它正在定义。
奇怪的是,我第一次创建模板应用程序时,它在导入库中具有不同的模板和更多行,但是在第二次尝试后,导入行仅限于:import 'package:flutter/material.dart';
,其中当然不包括{{1 }}
runApp()
错误
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
答案 0 :(得分:2)
显然SDK中存在损坏的文件,请通过C:\src\flutter
重新安装SDK来解决此问题。