在flutter

问题描述 投票:0回答:1

enter image description here

->在上面的代码中,我在我的widgets_test.dart文件中遇到问题,其中它的讲述找不到上述代码中的类名。

->但是我已经更改了代码,就像没有“ myApp”类,我一直在runapp()函数中直接调用“材料app”类,所以请帮助解决此问题。

enter image description here

在intery上,在widgets_test.dart中,您有此代码:
flutter dart android-studio android-virtual-device flutter-plugin
1个回答
0
投票
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() {}


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.