Skip to content

Possibility to arrange SegmentedButton vertically #150416

Closed
@RoarGronmo

Description

@RoarGronmo

Use case

I see that SegmentedButton are only ment to be horizontal, but we often see the need to arrange them vertically.
An example below (snipped from an android/kotlin app):
image

Proposal

Please add a direction parameter in SegmentedButton, which turns the direction of the layout.
...such as this one, actually suggested from Gemini:

import 'package:flutter/material.dart';

// ...

SegmentedButton<int>(
  style: ButtonStyle(
    // Customize the button style for verticalorientation
    padding: MaterialStateProperty.all(EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0)),
    textStyle: MaterialStateProperty.all(TextStyle(fontSize: 16.0)),
    // Add more styling as needed
  ),
  segments: const <ButtonSegment<int>>[
    ButtonSegment<int>(value: 0, label: Text('Option 1')),
    ButtonSegment<int>(value: 1, label: Text('Option 2')),
    ButtonSegment<int>(value: 2, label: Text('Option 3')),
    // Add more segments as needed
  ],
  selected: <int>{0}, // Set initial selection
  onSelectionChanged: (Set<int> newSelection) {
    // Handle selection changes
    print('Selected segment: ${newSelection.first}');
  },
  direction: Axis.vertical, // Set the direction to vertical
)

image

the call has been forwarded...

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions