Unable to implement ‘if int value >= 75’ then proceed to next page logic

You’re not using the parameter a, you use percentage on the if statement.

void checkpercent(int a) {
    if (a >= 75) {
      Navigator.push(
          context, MaterialPageRoute(builder: (context) => const CertScreen()));
    }
  }

Also your int percentage = int.parse(percentController.text); at the start of main.dart should be called before the checkpercent function so it receives the latest value.

ElevatedButton(
          child: const Text('Submit'),
          onPressed: () {
            int percentage = int.parse(percentController.text);
            checkpercent(percentage);
          },
        ),

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top