Closed ShamsArfeen closed 2 years ago
I traced the issue and finally found the root of the problem. It is kind of an unexpected behavior to me.
Problem: Dialogue wont close if your app's main() is like this
void main() { runApp(new MaterialApp( home: new MyApp(), )); }
Consider changing main() to following, and the dialogues will dismiss normally then void main() => runApp( new MyApp());
void main() => runApp( new MyApp());
For somebody who wants to reproduce the error or want specific error example, here is the main.dart file.
import 'package:flutter/material.dart'; void main() { runApp(new MaterialApp( home: new MyApp(), )); } // Changing main() to following solves the dismissing problem /* void main() => runApp( new MyApp()); */ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Fancy Dialog Example', theme: ThemeData.dark(), home: new HomePage(), ); } } class HomePage extends StatefulWidget { HomePage({ Key key, }) : super(key: key); @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Awesome Dialog Example'), ), body: Center( child: Container( padding: EdgeInsets.all(16), child: SingleChildScrollView( child: Column( children: <Widget>[ SizedBox( height: 100, ), AnimatedButton( text: 'Succes Dialog', color: Colors.green, pressEvent: () { AwesomeDialog( context: context, animType: AnimType.LEFTSLIDE, headerAnimationLoop: false, dialogType: DialogType.SUCCES, title: 'Succes', desc: 'Dialog description here..................................................', btnOkOnPress: () { debugPrint('OnClcik'); }, btnOkIcon: Icons.check_circle, onDissmissCallback: () { debugPrint('Dialog Dissmiss from callback'); }) ..show(); }, ), SizedBox( height: 16, ), ], ), ), ))); } }
Is the problem still persisting? The code seems to work just fine for me.
I traced the issue and finally found the root of the problem. It is kind of an unexpected behavior to me.
Problem: Dialogue wont close if your app's main() is like this
void main() { runApp(new MaterialApp( home: new MyApp(), )); }
Consider changing main() to following, and the dialogues will dismiss normally then
void main() => runApp( new MyApp());
For somebody who wants to reproduce the error or want specific error example, here is the main.dart file.