问题描述
我正在尝试使用 flutter创建app_name
来测试抖动,并使用Android Studio和VS Code,我未定义 runApp
上的错误,并且实际上没有任何地方在flutter库中,我可以看到它正在定义.
I'm trying to test flutter with flutter create app_name
and using Android Studio and VS Code I get the error on runApp
isn't defined, and indeed no where in the flutter library I can see this is being defined.
奇怪的是,我第一次创建模板应用程序时,它在导入库中有一个不同的模板和更多行,但是在第二次尝试后,导入行仅限于:当然不包含 runApp()
Strangely, first time I created a template app it had a different template and more lines at import library but after second attempt the import line is only one limited to: import 'package:flutter/material.dart';
which of course does not include 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'),
);
}
}
错误
C:\Works\flutter_udemy_course_blank2>flutter run
Using hardware rendering with device AOSP on IA Emulator. If you get graphics artifacts, consider enabling software
rendering with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Compiler message:
/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart:1039:69: Error: Type 'WidgetsBindingObserver' not found.
class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindingObserver {
^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:711:55: Error: Type 'WidgetsBindingObserver' not found.
class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1205:77: Error: Type 'WidgetsBindingObserver' not found.
class _MediaQueryFromWindowsState extends State<_MediaQueryFromWindow> with WidgetsBindingObserver {
^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart:1062:103: Error: Type 'WidgetsBindingObserver' not found.
class EditableTextState extends State<EditableText> with AutomaticKeepAliveClientMixin<EditableText>, WidgetsBindingObserver, TickerProviderStateMixin<EditableText> implements TextInputClient, TextSelectionDelegate {
^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart:941:45: Error: Type 'WidgetsBindingObserver' not found.
class _ImageState extends State<Image> with WidgetsBindingObserver {
^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:51:69: Error: Type 'WidgetsBindingObserver' not found.
class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindingObserver {
^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:2098:10: Error: Type 'WidgetsBindingObserver' not found.
with WidgetsBindingObserver {
^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart:941:7: Error: The type 'WidgetsBindingObserver' can't be mixed in.
class _ImageState extends State<Image> with WidgetsBindingObserver {
^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:51:7: Error: The type 'WidgetsBindingObserver' can't be mixed in.
class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindingObserver {
^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:2097:7: Error: The type 'WidgetsBindingObserver' can't be mixed in.
class _WidgetInspectorState extends State<WidgetInspector>
^
/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart:1039:7: Error: The type 'WidgetsBindingObserver' can't be mixed in.
class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindingObserver {
^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:711:7: Error: The type 'WidgetsBindingObserver' can't be mixed in.
class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1205:7: Error: The type 'WidgetsBindingObserver' can't be mixed in.
class _MediaQueryFromWindowsState extends State<_MediaQueryFromWindow> with WidgetsBindingObserver {
^
/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart:1062:7: Error: The type 'WidgetsBindingObserver' can't be mixed in.
class EditableTextState extends State<EditableText> with AutomaticKeepAliveClientMixin<EditableText>, WidgetsBindingObserver, TickerProviderStateMixin<EditableText> implements TextInputClient, TextSelectionDelegate {
^
lib/main.dart:9:3: Error: Method not found: 'runApp'.
runApp(new MyApp());
^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart:1066:39: Error: The getter 'WidgetsBinding' isn't defined for the class '_DropdownButtonState<T>'.
- '_DropdownButtonState' is from 'package:flutter/src/material/dropdown.dart' ('/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
final FocusManager focusManager = WidgetsBinding.instance.focusManager;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart:1073:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_DropdownButtonState<T>'.
- '_DropdownButtonState' is from 'package:flutter/src/material/dropdown.dart' ('/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.removeObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart:1075:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_DropdownButtonState<T>'.
- '_DropdownButtonState' is from 'package:flutter/src/material/dropdown.dart' ('/C:/src/flutter/packages/flutter/lib/src/material/dropdown.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.focusManager.removeHighlightModeListener(_handleFocusHighlightModeChange);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:718:31: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetsAppState'.
- '_WidgetsAppState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
_locale = _resolveLocales(WidgetsBinding.instance.window.locales, widget.supportedLocales);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:719:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetsAppState'.
- '_WidgetsAppState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.addObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:731:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetsAppState'.
- '_WidgetsAppState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.removeObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1071:23: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetsAppState'.
- '_WidgetsAppState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
initialRoute: WidgetsBinding.instance.window.defaultRouteName != Navigator.defaultRouteName
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1072:15: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetsAppState'.
- '_WidgetsAppState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
? WidgetsBinding.instance.window.defaultRouteName
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1073:38: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetsAppState'.
- '_WidgetsAppState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
: widget.initialRoute ?? WidgetsBinding.instance.window.defaultRouteName,
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1209:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_MediaQueryFromWindowsState'.
- '_MediaQueryFromWindowsState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.addObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1254:39: Error: The getter 'WidgetsBinding' isn't defined for the class '_MediaQueryFromWindowsState'.
- '_MediaQueryFromWindowsState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window),
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart:1261:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_MediaQueryFromWindowsState'.
- '_MediaQueryFromWindowsState' is from 'package:flutter/src/widgets/app.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/app.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.removeObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/binding.dart:10:45: Error: The argument type 'Type' can't be assigned to the parameter type 'PreferredSizeWidget'.
- 'Type' is from 'dart:core'.
- 'PreferredSizeWidget' is from 'package:flutter/src/widgets/preferred_size.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/preferred_size.dart').
return MaterialApp(home: Scaffold(appBar: AppBar ,),);
^
/C:/src/flutter/packages/flutter/lib/src/widgets/drag_target.dart:633:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_DragAvatar<T>'.
- '_DragAvatar' is from 'package:flutter/src/widgets/drag_target.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/drag_target.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.hitTest(result, globalPosition + feedbackOffset);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart:1590:32: Error: The getter 'WidgetsBinding' isn't defined for the class 'EditableTextState'.
- 'EditableTextState' is from 'package:flutter/src/widgets/editable_text.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
if (_lastBottomViewInset < WidgetsBinding.instance.window.viewInsets.bottom) {
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart:1593:28: Error: The getter 'WidgetsBinding' isn't defined for the class 'EditableTextState'.
- 'EditableTextState' is from 'package:flutter/src/widgets/editable_text.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
_lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart:1712:7: Error: The getter 'WidgetsBinding' isn't defined for the class 'EditableTextState'.
- 'EditableTextState' is from 'package:flutter/src/widgets/editable_text.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.addObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart:1713:30: Error: The getter 'WidgetsBinding' isn't defined for the class 'EditableTextState'.
- 'EditableTextState' is from 'package:flutter/src/widgets/editable_text.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
_lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart:1720:7: Error: The getter 'WidgetsBinding' isn't defined for the class 'EditableTextState'.
- 'EditableTextState' is from 'package:flutter/src/widgets/editable_text.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/editable_text.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.removeObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/focus_manager.dart:1152:39: Error: Getter not found: 'WidgetsBinding'.
static FocusManager get instance => WidgetsBinding.instance.focusManager;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/focus_manager.dart:1210:75: Error: The getter 'WidgetsBinding' isn't defined for the class 'FocusManager'.
- 'FocusManager' is from 'package:flutter/src/widgets/focus_manager.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/focus_manager.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
_lastInteractionWasTouch ??= Platform.isAndroid || Platform.isIOS || !WidgetsBinding.instance.mouseTracker.mouseIsConnected;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/focus_manager.dart:1433:31: Error: Getter not found: 'WidgetsBinding'.
FocusNode get primaryFocus => WidgetsBinding.instance.focusManager.primaryFocus;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/focus_manager.dart:1440:10: Error: Getter not found: 'WidgetsBinding'.
assert(WidgetsBinding.instance != null);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/heroes.dart:803:9: Error: The getter 'WidgetsBinding' isn't defined for the class 'HeroController'.
- 'HeroController' is from 'package:flutter/src/widgets/heroes.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/heroes.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.addPostFrameCallback((Duration value) {
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart:953:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_ImageState'.
- '_ImageState' is from 'package:flutter/src/widgets/image.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.addObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart:959:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_ImageState'.
- '_ImageState' is from 'package:flutter/src/widgets/image.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.removeObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart:991:11: Error: Superclass has no method named 'didChangeAccessibilityFeatures'.
super.didChangeAccessibilityFeatures();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/localizations.dart:522:7: Error: The getter 'WidgetsBinding' isn't defined for the class '_LocalizationsState'.
- '_LocalizationsState' is from 'package:flutter/src/widgets/localizations.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/localizations.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.deferFirstFrameReport();
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/localizations.dart:524:9: Error: The getter 'WidgetsBinding' isn't defined for the class '_LocalizationsState'.
- '_LocalizationsState' is from 'package:flutter/src/widgets/localizations.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/localizations.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.allowFirstFrameReport();
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/navigator.dart:2325:38: Error: The getter 'WidgetsBinding' isn't defined for the class 'NavigatorState'.
- 'NavigatorState' is from 'package:flutter/src/widgets/navigator.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/navigator.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
_activePointers.toList().forEach(WidgetsBinding.instance.cancelPointer);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/scroll_physics.dart:209:30: Error: Getter not found: 'WidgetsBinding'.
velocity: 1.0 / (0.050 * WidgetsBinding.instance.window.devicePixelRatio), // logical pixels per second
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/scroll_physics.dart:210:21: Error: Getter not found: 'WidgetsBinding'.
distance: 1.0 / WidgetsBinding.instance.window.devicePixelRatio, // logical pixels
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:61:32: Error: The getter 'WidgetsBinding' isn't defined for the class '_SemanticsDebuggerState'.
- '_SemanticsDebuggerState' is from 'package:flutter/src/widgets/semantics_debugger.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
_client = _SemanticsClient(WidgetsBinding.instance.pipelineOwner)
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:63:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_SemanticsDebuggerState'.
- '_SemanticsDebuggerState' is from 'package:flutter/src/widgets/semantics_debugger.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.addObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:71:5: Error: The getter 'WidgetsBinding' isn't defined for the class '_SemanticsDebuggerState'.
- '_SemanticsDebuggerState' is from 'package:flutter/src/widgets/semantics_debugger.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.removeObserver(this);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:106:51: Error: The getter 'WidgetsBinding' isn't defined for the class '_SemanticsDebuggerState'.
- '_SemanticsDebuggerState' is from 'package:flutter/src/widgets/semantics_debugger.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
_lastPointerDownLocation = event.position * WidgetsBinding.instance.window.devicePixelRatio;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:158:39: Error: The getter 'WidgetsBinding' isn't defined for the class '_SemanticsDebuggerState'.
- '_SemanticsDebuggerState' is from 'package:flutter/src/widgets/semantics_debugger.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
PipelineOwner get _pipelineOwner => WidgetsBinding.instance.pipelineOwner;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart:167:9: Error: The getter 'WidgetsBinding' isn't defined for the class '_SemanticsDebuggerState'.
- '_SemanticsDebuggerState' is from 'package:flutter/src/widgets/semantics_debugger.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/semantics_debugger.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.window.devicePixelRatio,
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:904:11: Error: 'WidgetsBinding' isn't a type.
final WidgetsBinding binding = WidgetsBinding.instance;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:904:36: Error: The getter 'WidgetsBinding' isn't defined for the class 'WidgetInspectorService'.
- 'WidgetInspectorService' is from 'package:flutter/src/widgets/widget_inspector.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
final WidgetsBinding binding = WidgetsBinding.instance;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:1228:12: Error: The getter 'WidgetsBinding' isn't defined for the class 'WidgetInspectorService'.
- 'WidgetInspectorService' is from 'package:flutter/src/widgets/widget_inspector.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
return WidgetsBinding.instance != null &&
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:1229:12: Error: The getter 'WidgetsBinding' isn't defined for the class 'WidgetInspectorService'.
- 'WidgetInspectorService' is from 'package:flutter/src/widgets/widget_inspector.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance.debugDidSendFirstFrameEvent;
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:1592:24: Error: The getter 'WidgetsBinding' isn't defined for the class 'WidgetInspectorService'.
- 'WidgetInspectorService' is from 'package:flutter/src/widgets/widget_inspector.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
return _nodeToJson(WidgetsBinding.instance?.renderViewElement?.toDiagnosticsNode(), _SerializationDelegate(groupName: groupName, service: this));
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:1603:7: Error: The getter 'WidgetsBinding' isn't defined for the class 'WidgetInspectorService'.
- 'WidgetInspectorService' is from 'package:flutter/src/widgets/widget_inspector.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
WidgetsBinding.instance?.renderViewElement?.toDiagnosticsNode(),
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:2243:41: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetInspectorState'.
- '_WidgetInspectorState' is from 'package:flutter/src/widgets/widget_inspector.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
final Rect bounds = (Offset.zero & (WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio)).deflate(_kOffScreenMargin);
^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart:2243:87: Error: The getter 'WidgetsBinding' isn't defined for the class '_WidgetInspectorState'.
- '_WidgetInspectorState' is from 'package:flutter/src/widgets/widget_inspector.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'WidgetsBinding'.
final Rect bounds = (Offset.zero & (WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio)).deflate(_kOffScreenMargin);
^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 24s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 24.9s
Gradle task assembleDebug failed with exit code 1
推荐答案
显然SDK中存在损坏的文件,可以通过 C:\ src \ flutter
重新安装SDK来解决此问题.
Apparently there were corrupt file in SDK, reinstalling the SDK at C:\src\flutter
fixed the issue.
这篇关于Fresh Flutter项目有错误:未定义函数"runApp"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!