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

Or something looks wrong: When OverflowBox is used inside a ScrollView and the view is of scrollable length the OverflowBox would not extend to screen width. Works fine when the view is not of scrollable length. #147055

Closed
ignicubeLaeeq opened this issue Apr 19, 2024 · 2 comments
Labels
r: solved Issue is closed as solved

Comments

@ignicubeLaeeq
Copy link

ignicubeLaeeq commented Apr 19, 2024

Steps to reproduce

  1. Create a simple flutter scaffold application.
  2. Add Column to the body.
  3. Wrap Column with SingleChildScrollView and Padding.
  4. Add following overflow box to children of Column:
Center(
          child: Container(
            height: 200,
            width: 100,
            color: Colors.red.shade100,
            child: OverflowBox(
              maxWidth: MediaQuery.of(context).size.width,
              minHeight: 100,
              maxHeight: 150,
              child: Container(
                color: Colors.amber,
                height: 100,
              ),
            ),
          ),
        ),

This should render fine with amber box going to the edges of the screen.

  1. Add Container to column with enough height that scroll is activated.

The yellow box no longer extends to the edge of the screen and is cropped by the padding.

Expected results

The overflow box should extend to the edge of the screen even if the view is scrollabale.

Actual results

OverflowBox not going to the edge of the screen horizontally when view is of enough height that it can scroll.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    title: 'Flutter Demo',
    theme: ThemeData(
      colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
      useMaterial3: true,
    ),
    debugShowCheckedModeBanner: false,
    home: const MyHomePage(),
  ));
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Home page'),
        centerTitle: true,
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: SingleChildScrollView(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Center(
                  child: Container(
                    height: 200,
                    width: 100,
                    color: Colors.red.shade100,
                    child: OverflowBox(
                      maxWidth: MediaQuery.of(context).size.width,
                      minHeight: 100,
                      maxHeight: 150,
                      child: Container(
                        color: Colors.amber,
                        height: 100,
                      ),
                    ),
                  ),
                ),
                // SizedBox(
                //   height: MediaQuery.of(context).size.height,
                // ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
variant1 variant2

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]
@huycozy huycozy added the in triage Presently being triaged by the triage team label Apr 22, 2024
@huycozy
Copy link
Member

huycozy commented Apr 22, 2024

Hi @ignicubeLaeeq
The default clipBehavior in SingleChildScrollView is Clip.hardEdge which enables clipping. This will be fixed by using Clip.none instead.

I will close the issue as solved. If it doesn't fit your case, please write in comments and I will re-open this and take another look! Thank you!

@huycozy huycozy closed this as completed Apr 22, 2024
@huycozy huycozy added r: solved Issue is closed as solved and removed in triage Presently being triaged by the triage team labels Apr 22, 2024
Copy link

github-actions bot commented May 6, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: solved Issue is closed as solved
Projects
None yet
Development

No branches or pull requests

2 participants