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

The type of the right operand ('ConfirmAction') isn't a subtype or a > supertype of the left operand ('Future<ConfirmAction?>')

How to fix

The type of the right operand (‘ConfirmAction’) isn’t a subtype or a
supertype of the left operand (‘Future<ConfirmAction?>’).

this does not cause runtime errors, but it does show the recommendation in the IDE

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

return Dismissible(
      key: UniqueKey(),
      direction: DismissDirection.horizontal,
      onDismissed: (direction) async {
        await _asyncConfirmDialog(context).then((value) {    
          if (value == ConfirmAction.cancel) { //here
            ...

>Solution :

I don’t know what happens inside _asyncConfirmDialog, but it looks like the returned value is of type Future<Future<ConfirmAction?>>, which makes value has the type of Future<ConfirmAction?>. You need to put the await keyword to make it a ConfirmAction? (which is comparable to ConfirmAction)

await _asyncConfirmDialog(context).then((value) async { // (1) put async here    
  if (await value == ConfirmAction.cancel) { // (2) put await here
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