The name 'MyApp' isn't a class. Try correcting the name to match an existing class. flutter
2,750
On the pumpWidget method change "const MyApp()" to the same name of your first Widget class. The class you instance on the runApp function inside the main function on the main.dart file.
For example, if your main.dart content is:
void main() async {
runApp(MyGreatApp());
}
class MyGreatApp extends StatelessWidget {
const MyGreatApp();
@override
Widget build(BuildContext context) {
return MaterialApp(
//rest of code ...
);
}
}
Put in your widget_test.dart file:
await tester.pumpWidget(const MyGreatApp()); //<-
Author by
Leskeboy
Updated on January 01, 2023Comments
-
Leskeboy over 1 year
I don't know what is the problem is / how to fix this while I tring to code it shows this error on the test folder widget_test.dart
testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp());
-
princesanjivy over 2 yearsYou need to keep the name of the root widget class
-