Showing dialog from inside another dialog

Issue

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?

Solution

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.

Answered By – Wilson Wilson

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *