Flutter: Problem with platform specific dialog

490 views Asked by At

I am trying to make a platform specific dialog, but mine solution all the time shows android (i am working on iphone simulator). Do you have any idea what is the problem?

    onTap: () => _onDeletePanel(context),
          ),
        ],
      ),
    );
  }
}

Future<void> _onDeletePanel(BuildContext context) async {
  if (!Platform.isMacOS) {
    await showDialog<bool>(
      barrierDismissible: false,
      context: context,
      builder: (context) => AppConfirmationDialog(
        title: 'Are you sure?',
        contentText: 'Would you like to delete this?',
        confirmText: I10n.of(context).reset,
      ),
    );
  } else {
    await showCupertinoDialog<bool>(
      context: context,
      builder: (context) => CupertinoAlertDialog(
        title: Text('Are you sure?'),
        content: Text('Would you like to delete this?'),
        actions: [],
      ),
    );
  }
}
1

There are 1 answers

0
Gwhyyy On

like you've uset the Platform.isMacOS to execute some code, do the same for the other platforms you target Platform.isIOS

else if(Platform.isIOS) {
  //your code
  }