Pass values to child in LayoutBuilder

251 views Asked by At

I'm using LayoutBuilder and would like to pass values to a child widget:

LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constraints) {
        return Padding(
          padding: const EdgeInsets.all(constraints.maxWidth / 10),

But I'm getting the error

Invalid constant value

Is there a way to pass constraints.maxWidth to the child widget?

1

There are 1 answers

0
Afridi Kayal On BEST ANSWER

Remove the const keyword before EdgeInsets.all because constraints.maxWidth is not a constant term