Home > Blockchain >  Can't pass value in the function
Can't pass value in the function

Time:02-05

quiz.dart snippet main.dart snippet

source code: https://github.com/faseehhyder/first_application

I'm trying to pass score as int in the function but dunno why I can't do that.

CodePudding user response:

VoidCallback == void Function() but you are passing void Function(int) to this. try replacing VoidCallback to void Function(int)

CodePudding user response:

Use final Function answerQuestion; instead of final VoidCallback answerQuestion;

CodePudding user response:

I'm trying to pass a Value from when a button is clicked, What I want in the code is to pass the value from the Button Widget to another Page's Variable named pdfNo. Here's my code:

FlatButton(
          padding: EdgeInsets.fromLTRB(2, 5, 5, 5),
          child: ListTile(
            leading: Icon(Icons.book, color: Color(0xFFEB3549)),
            title: Text('Book5'),
          ),
          onPressed: () {
            Navigator.push(
                context,
                MaterialPageRoute(
                builder: (context) => PDFPage() ));
            print('Pressed 6');
          },
        ),`
  •  Tags:  
  • Related