Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElevatedColumn doesn't support overflow when wrapped in a SingleChildScrollView #3

Open
liam-hp opened this issue Aug 30, 2024 · 1 comment

Comments

@liam-hp
Copy link

liam-hp commented Aug 30, 2024

As described, while a normal Column allows for overflow even when wrapped in a SingleChildScrollView, ElevatedColumn cuts off the overflow. Interestingly, it allows for the overflow without the scroll view.

Minimal example:

Scaffold(
  body: Container(
    color: Colors.white,
    height: globals.screenH,
    width: globals.screenW,
    alignment: Alignment.center,
    child: Container(
      height: 400,
      width: 200,
      color: Colors.grey,
      alignment: Alignment.topCenter,
      child: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        child: Column( // Replacing this Column with ElevatedColumn stops overflow
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Container(
              color: Colors.black,
              height: 50,
              width: 200,
              alignment: Alignment.center,
              child: OverflowBox(
                maxHeight: 200,
                maxWidth: 200,
                child: Container(
                  color: Colors.red.withOpacity(.5),
                  height: 150,
                  width: 150,
                )
              )
            ),
          ]
        ),
      ),
    )
  )
);
@lukas-pierce
Copy link
Owner

@liam-hp Just add clipBehavior: Clip.none to SingleChildScrollView

Full working example:

import 'package:flutter/material.dart';
import 'package:elevated_flex/elevated_flex.dart';

// hardcoded sizes for iPhone 15 Pro Max
final class globals {
  static const double screenH = 932;
  static const double screenW = 430;
}

class TestElevatedFlex extends StatelessWidget {
  const TestElevatedFlex({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: Colors.white,
        height: globals.screenH,
        width: globals.screenW,
        alignment: Alignment.center,
        child: Container(
          height: 400,
          width: 200,
          color: Colors.grey,
          alignment: Alignment.topCenter,
          child: SingleChildScrollView(
            clipBehavior: Clip.none, // <---------------------------- add this
            scrollDirection: Axis.vertical,
            child: ElevatedColumn( // Replacing this Column with ElevatedColumn stops overflow
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Container(
                  color: Colors.black,
                  height: 50,
                  width: 200,
                  alignment: Alignment.center,
                  child: OverflowBox(
                    maxHeight: 200,
                    maxWidth: 200,
                    child: Container(
                      color: Colors.red.withOpacity(.5),
                      height: 150,
                      width: 150,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants