-> In the above code I am having problem in my widgets_test.dart file where its telling can't find the class name in my above code.
-> But I have changed my code like there is no "MyApp" class, I have been calling "MaterialApp" class directly in runApp() function, so please help to fix this.
-> In the above code I am having problem in my widgets_test.dart file where its telling can't find the class name in my above code.
-> But I have changed my code like there is no "MyApp" class, I have been calling "MaterialApp" class directly in runApp() function, so please help to fix this.
Share Improve this question edited 2 hours ago DarkBee 15.6k8 gold badges70 silver badges115 bronze badges asked 9 hours ago PankajPankaj 212 bronze badges 2- You could put the CameraAccess class in widget_test.dart file – Rutvik Gumasana Commented 9 hours ago
- Please do not upload images of code/data/errors. - Please edit and provide the code/data/errors as text. – DarkBee Commented 2 hours ago
2 Answers
Reset to default 0Initially, in widgets_test.dart, you have this code:
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);
});
}
Since you deleted the MyApp class from main.dart file, then you get the error, because the program cant find the class. You can delete the code from widgets_test.dart file, and have just this:
void main() {}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My Flutter App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
In MyApp, there should be a StatelessWidget that contains Material components.
runApp(MyApp();