@@ -685,47 +685,45 @@ class SampleMenu extends StatelessWidget {
685685 }
686686
687687 Future <bool > _showConfirm (BuildContext context, String message) async {
688- final dynamic result = await showDialog <bool >(
689- context: context,
690- builder: (BuildContext ctx) {
691- return AlertDialog (
692- content: Text (message),
693- actions: < Widget > [
694- TextButton (
695- onPressed: () {
696- Navigator .of (ctx).pop (false );
697- },
698- child: const Text ('Cancel' )),
699- TextButton (
700- onPressed: () {
701- Navigator .of (ctx).pop (true );
702- },
703- child: const Text ('OK' )),
704- ],
705- );
706- });
707-
708- return result.runtimeType == bool && result as bool ;
688+ return await showDialog <bool >(
689+ context: context,
690+ builder: (BuildContext ctx) {
691+ return AlertDialog (
692+ content: Text (message),
693+ actions: < Widget > [
694+ TextButton (
695+ onPressed: () {
696+ Navigator .of (ctx).pop (false );
697+ },
698+ child: const Text ('Cancel' )),
699+ TextButton (
700+ onPressed: () {
701+ Navigator .of (ctx).pop (true );
702+ },
703+ child: const Text ('OK' )),
704+ ],
705+ );
706+ }) ??
707+ false ;
709708 }
710709
711710 Future <String > _showTextInput (
712711 BuildContext context, String message, String ? defaultText) async {
713- final dynamic result = await showDialog <String >(
714- context: context,
715- builder: (BuildContext ctx) {
716- return AlertDialog (
717- content: Text (message),
718- actions: < Widget > [
719- TextButton (
720- onPressed: () {
721- Navigator .of (ctx).pop ('Text test' );
722- },
723- child: const Text ('Enter' )),
724- ],
725- );
726- });
727-
728- return result.runtimeType == String ? result as String : '' ;
712+ return await showDialog <String >(
713+ context: context,
714+ builder: (BuildContext ctx) {
715+ return AlertDialog (
716+ content: Text (message),
717+ actions: < Widget > [
718+ TextButton (
719+ onPressed: () {
720+ Navigator .of (ctx).pop ('Text test' );
721+ },
722+ child: const Text ('Enter' )),
723+ ],
724+ );
725+ }) ??
726+ '' ;
729727 }
730728}
731729
0 commit comments