Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

can someone explain to me why 1 positional argument expected but 0 found

I am new to Flutter. I’m trying to make another alert dialog window after I click Yes on first alert dialog, but there is an error. The error was at my showSecond(); The outcome somehow will be like this. It would be a pleasure if someone can explain to me ;( and show me the right one. Thank you so much!

This is my code.

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:smart_parking/features/home/homescreen.dart';

class MyBottomBar extends StatelessWidget {
  const MyBottomBar({ Key? key }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container( 
      height: 50, 
      width: double.maxFinite, 
      decoration: BoxDecoration( 
        color: Colors.grey.shade200
      ),

      child: Row( 
        
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget> [ 
          Column( 
            crossAxisAlignment: CrossAxisAlignment.start, 
            children: [ 
              
              Text('Total payment', style: TextStyle( fontSize: 15, decoration: TextDecoration.none, color: Colors.grey.shade800)), 
              SizedBox(height: 5), 
              Text('RM 46.00', style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 10, decoration: TextDecoration.none),)
            ],
          ), 
          SizedBox( width: 90),

          Image.asset('boxP.png', height: 30, width: 50), 

          Spacer(),
          Column( 
            children: [ 
              Container( height: 50, width: 150, color: Colors.black,
                child: Align( 
                  alignment: Alignment.center, 
                  child: TextButton(child: Text('PAY', style: TextStyle(color: Colors.white)),
                  onPressed: () { 
                    showAlertDialog(context);
                  },),
                ),
              )
            ],
          ),
        ]
      ),
    );
  }
}

void showAlertDialog(BuildContext context) {
  showDialog(context: context,
   builder: (BuildContext context) 
   { return CupertinoAlertDialog( 
     title: Text("Payment Confirmation", style: TextStyle( fontWeight: FontWeight.bold),), 
     content: Text("Are you sure with your payment?"), 
     actions: [ 
       CupertinoDialogAction(child: Text('Cancel'), 
       onPressed: () { Navigator.of(context).pop();
       }
       ), 
       CupertinoDialogAction
       (child: Text("Yes"), 
       onPressed: () { 
         Navigator.push(context, 
         MaterialPageRoute(builder: (context) => const HomeScreen()));
        showSecond();
       }, 
       )

     ],
   ); 
   }, );
}

void showSecond( BuildContext context) {
   showDialog(
      context: context,
      builder: (BuildContext context) => AlertDialog(
        title: Text("Thank you for paying with us"),
        content: Icon(Icons.check_circle_outline),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: const Text('Okay'),
          ),
        ],
      ),
    );
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

try this one bro

  onPressed: () {
            Navigator.push(context,
                MaterialPageRoute(builder: (context) => const HomeScreen()));
            showSecond(context);
          },
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading