just new to Flutter but very impressed. I want to show a Dialog if a PushNotification arrives via Firebase \"onMessage\".
But every Time I get a Exception \"No MaterialL
In Order to Fix the error, You need to Call Your Main
class as a home parameter of MaterialApp
as Like Below.
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
debugShowCheckedModeBanner: false,
home: Main(),
);
}
}
& update your Build Method in Main
Class as:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: Column(children: [
Center(
child: Text('Hello World'),
),
RaisedButton(
onPressed: () {
print("pushed?");
_showPushDialog(context);
},
child: Text("press me"),
)
]),
);
}