->但是我已经更改了代码,就像没有“ myApp”类,我一直在runapp()函数中直接调用“材料app”类,所以请帮助解决此问题。
在intery上,在widgets_test.dart中,您有此代码:import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async
{
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
当您从main.dart文件中删除MyApp类,然后您会收到错误,因为程序无法找到类。您只需从widgets_test.dart文件删除代码,然后就以下内容:
void main() {}