I am doing widget testing but I got Error: The getter 'mounted' isn't defined for the class 'BuildContext'.. How can I fix this error?
fvm flutter --version Flutter 3.7.12 • channel stable • https://github.com/flutter/flutter.git Framework • revision 4d9e56e694 (3 months ago) • 2023-04-17 21:47:46 -0400 Engine • revision 1a65d409c7 Tools • Dart 2.19.6 • DevTools 2.20.1
void main() {
setupLocator();
const testWidget = MediaQuery(
data: MediaQueryData(),
child: MaterialApp(
home: CommitteeHubView(),
),
);
testWidgets("CommitteeHubView", (WidgetTester tester) async {
await tester.pumpWidget(testWidget);
expect(find.text('Committee Hub'), findsOneWidget);
});
}
: Error: The getter 'mounted' isn't defined for the class 'BuildContext'. rm.dart:2127
'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../../flutter/packages/flutter/lib/src/widgets/framework.dart'). framework.dart:1 Try correcting the name to the name of an existing getter, or defining a getter or field named 'mounted'.
_contextSet.last.mounted ? _contextSet.last.findRenderObject() : null; ^^^^^^^
Failed to load "/Users/jaehyuckchoi/Desktop/resvu/untitled folder/communitilink_flutter_app/test/view/committee_hub/committee_hub_view_test.dart": Compilation failed for testPath=/Users/jaehyuckchoi/Desktop/resvu/untitled folder/communitilink_flutter_app/test/view/committee_hub/committee_hub_view_test.dart
✖ loading /Users/jaehyuckchoi/Desktop/resvu/untitled folder/communitilink_flutter_app/test/view/committee_hub/committee_hub_view_test.dart Exited (1)