FlutterExampleApps icon indicating copy to clipboard operation
FlutterExampleApps copied to clipboard

The fuction 'MyApp' is not defined

Open ghost opened this issue 5 years ago • 6 comments

my code is right but I don't know why it is showing issue. By the way I use Ubuntu Error

ghost avatar Dec 06 '20 15:12 ghost

my code is right but I don't know why it is showing issue. By the way I use Ubuntu Error

The solution can be found out here

sdoshi983 avatar Dec 07 '20 17:12 sdoshi983

Simply, import MyApp in your widget_test.dart.

valen-developer avatar Jan 10 '21 18:01 valen-developer

I would like to be assigned to this

JaiAravindh-git avatar Feb 03 '21 17:02 JaiAravindh-git

Actually This is a warning. Better you should define a class MyApp and call this class under runApp. Example: void main() { runApp(MyApp()); }

class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', debugShowCheckedModeBanner: false, theme: ThemeData( scaffoldBackgroundColor: Color(0xff1f1f1f), primarySwatch: Colors.blue, ),

I think this may solve this warning.

Ritik609 avatar Feb 26 '21 14:02 Ritik609

if you dont test your app, you can delete test folder for now.

01mahdivalipoor avatar Apr 15 '21 14:04 01mahdivalipoor

When we create a flutter project, by default flutter create a test folder that contains widget_test.dart. Inside that, the pumpWidget method requires a widget to build our app and trigger a frame. It is not necessary but can be used for widget testing purposes. By default, it takes a widget named MyApp which is the first root widget that flutter creates for you. I assume that you might have removed the boilerplate code, which in turn removed that widget. You can either provide the name of the root widget(the widget given to the runApp method) as an argument to that method or create a widget named MyApp which is the root widget. You can also just ignore the warning or delete the folder widget_test.dart.

Harikrishnan001 avatar Jun 01 '21 16:06 Harikrishnan001