2

How do you show a dialog from an already open dialog? Basically, nesting dialogs in Flutter.

When I try to use showDialog(); in Flutter from inside an already created dialog(for example, by clicking some link inside a dialog, another dialog should open on top of that dialog) I get the following lint error:

Flutter showDialog Lint Error

Does any one have any idea on how to solve this problem?

João Martins
  • 706
  • 1
  • 8
  • 20

1 Answers1

3

Nesting dialogs is VERY possible. You are facing an entirely different issue.

Right now, you have conflicting imports from the custom_alert_dialog package, and the material.dart.

To resolve the issue, you have to name one of the imports using the as keyword.

E.x

import 'dart:math' as math;

Then to use it:

// BEFORE 
final valueOfPi = pi;

// AFTER
final valueOfPi = math.pi

The syntax of everything remains the same, but whenever you want to use an object or type from the library, just add the keyword as a prefix.

Wilson Wilson
  • 3,296
  • 18
  • 50
  • Didn't work mate when I wrote `import 'blabla_custom_alert_dialog' as custom_alert_dialog` then CustomAlertDialog doesn't get detected as imported anymore – João Martins Jan 21 '21 at 11:50
  • Yes, now whenever you want to use it, you have to add that prefix before. I've added an example – Wilson Wilson Jan 21 '21 at 11:52