3

I would like to try to override the padding with an OverflowBox in SingleChildScrollView but I can't.

My sample :

Screen(
  child: Scaffold(
    backgroundColor: Palette.white,
    appBar: ExtendedAppBar(
      title: HeaderTitle(title: L.of(context).catalogFilterTitle, color: Palette.white),
      onCloseCallback: () => Navigator.of(context).pop(false),
    ),
    body: SingleChildScrollView(
      padding: const EdgeInsets.only(left: 17.0, right: 17.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          ...,
          Expanded(
            child: OverflowBox(
              maxWidth: MediaQuery.of(context).size.width,
              child: Container(
                color: Colors.red.shade300,
                child: Center(
                  child: Text('No padding on this one!'),
                ),
              ),
            ),
          ),
          ...,
        ],
      ),
    ),
    floatingActionButton: RaisedButton(
      ...
    ),
    floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
  ),
);

When I execute, I have this exception :

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: _RenderScrollSemantics#98805 relayoutBoundary=up7 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
The relevant error-causing widget was: 
...
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: _RenderSingleChildViewport#feeb7 relayoutBoundary=up13 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1694 pos 12: 'hasSize'
The relevant error-causing widget was: 
...
════════════════════════════════════════════════════════════════════════════════════════════════════

Someone can explain me why ? :)

Thanks in advance

dra9na
  • 41
  • 4

1 Answers1

1

For answer :

SingleChildScrollView(
      padding: const EdgeInsets.only(left: 17.0, right: 17.0),
      child: IntrinsicHeight(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Expanded(
              child: OverflowBox(
                maxWidth: MediaQuery.of(context).size.width,
                child: Container(
                  color: Colors.red.shade300,
                  child: Center(
                    child: Text('No padding on this one!'),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    )
dra9na
  • 41
  • 4