tsy
tsy

Reputation: 59

Incorrect use of ParentDataWidget. I don't think I have much of a choice here, do I?

IgnorePointer(
              child: cProtractor & darkModeOn
                  ? Positioned.fill(
                      child: Align(
                          alignment: Alignment.center,
                          child: Center(
                            child:
                                Image.asset('lib/assets/img/cprot2white.png',
                                    width: 500.0, height: 500.0),
                          )))
                  : SizedBox())
        ]));
  }
}

The above function switches on and off a protractor overlay for my Google Map. Its parent is a body: Stack(children: [. Is there any way to fix this or get rid of the error? The function is working.

Upvotes: 0

Views: 156

Answers (1)

Shardul Singh Gurjar
Shardul Singh Gurjar

Reputation: 257

You have to remove Ignore pointer as parent widget of Positioned Widget as Positioned widgets are placed directly inside Stack widgets.

You can achieve the same using below code

  Positioned.fill(
            child: Align(
                alignment: Alignment.center,
                child: IgnorePointer(
                  child: Center(
                    child: Image.asset('lib/assets/img/cprot2white.png',
                        width: 500.0, height: 500.0),
                  ),
                ))),

Here just the hierarchy of the widgets are changed

Upvotes: 1

Related Questions