-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Create a new project
- Write the provided code sample
- Run it (in my case, for web)
- Decrease the window size so the text in the ButtonSegment must be split into two or more lines.
- See the overflow error at the bottom
Expected results
The text should be split in multiple lines if necessary without throwing any overflow errors the same way other widgets do.
The expected behaviour can be seen replacing the SegmentedButton for any widget with contents that must be split into multiple lines with reduced width windows like an ElevatedButton:
ElevatedButton(
onPressed: () {},
child: const Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec euismod, nisl eget ultricies ultricies, nisl ni"),
)Actual results
An exception is thrown when the screen width is small, so the text in the ButtonSegment must be split into two or more lines:
======== Exception caught by rendering library =====================================================
The following assertion was thrown during layout:
A RenderFlex overflowed by 4.0 pixels on the bottom.
The relevant error-causing widget was:
Column Column:file:///K:/GitHub/cabron/lib/main.dart:34:20
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.
The specific RenderFlex in question is: RenderFlex#45c07 OVERFLOWING
... parentData: paintOffset=Offset(0.0, -177.1)
... constraints: BoxConstraints(w=767.2, h=911.2)
... size: Size(767.2, 911.2)
... direction: vertical
... mainAxisAlignment: start
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
====================================================================================================Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Issue with SegmentedButton',
home: DemoPage(),
);
}
}
enum Options {
a,
b,
}
class DemoPage extends StatelessWidget {
const DemoPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverFillRemaining(
hasScrollBody: false,
child: Column(
children: [
SegmentedButton(segments: const [
ButtonSegment<Options>(value: Options.a, label: Text("Any text that will be 2 or more lines when the width is too small to fit in a single line")),
ButtonSegment<Options>(value: Options.b, label: Text("Any text that will be 2 or more lines when the width is too small to fit in a single line")),
], selected: const <Options>{
Options.a
}, onSelectionChanged: (newSelection) {}),
// SizedBox used to force scrollable column
SizedBox(height: MediaQuery.of(context).size.height * 1.2, child: const Placeholder()),
],
),
)
],
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
With error (multiple lines of text):
Without error (text in single line):
Logs
No response
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.7.10, on Microsoft Windows [Version 10.0.22621.1702], locale en-150)
• Flutter version 3.7.10 on channel stable at K:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4b12645012 (6 weeks ago), 2023-04-03 17:46:48 -0700
• Engine revision ec975089ac
• Dart version 2.19.6
• DevTools version 2.20.1
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at C:\Users\guple\AppData\Local\Android\Sdk
• Platform android-33-ext4, build-tools 33.0.1
• ANDROID_HOME = C:\Users\guple\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.19)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
• Visual Studio Build Tools 2019 version 16.11.32901.82
• Windows 10 SDK version 10.0.19041.0
[✓] Android Studio (version 2022.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
[✓] VS Code (version 1.76.2)
• VS Code at C:\Users\guple\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.60.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1702]
• Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.93
• Edge (web) • edge • web-javascript • Microsoft Edge 113.0.1774.42
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!mockturtl
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue

