Skip to content

Add missing icon props in button styleFrom methods. #154798

@TahaTesser

Description

@TahaTesser

Steps to reproduce

Following button styleFrom methods are missing some icon props:

  • ElevatedButton.styleFrom (missing iconSize)
  • FilledButton.styleFrom (missing iconSize)
  • OutlinedButton.styleFrom (missing iconSize)
  • TextButton.styleFrom (missing iconSize)
  • MenuItemButton.styleFrom (missing iconSize and disabledIconColor)
  • SubmenuButton.styleFrom (missing iconSize and disabledIconColor)
  • SegmentedButton.styleFrom (missing iconSize, iconColor, and disabledIconColor)

Expected results

Can access all icon propers from regular ButtonStyle in styleFrom methods.

Actual results

Missing some icon props

Code sample

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

enum Calendar { day, week, month, year }

void main() => runApp(const MyApp());

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Calendar calendarView = Calendar.week;
  bool isEnabled = true;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: Column(
            spacing: 10.0,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ElevatedButton.icon(
                style: ElevatedButton.styleFrom(
                  iconSize: 30,
                  iconColor: Colors.red,
                  disabledIconColor: Colors.red.withValues(alpha: 0.5),
                ),
                onPressed: isEnabled ? () {} : null,
                icon: const Icon(Icons.add),
                label: const Text('ElevatedButton'),
              ),
              FilledButton.icon(
                style: ElevatedButton.styleFrom(
                  iconSize: 30,
                  iconColor: Colors.red,
                  disabledIconColor: Colors.red.withValues(alpha: 0.5),
                ),
                onPressed: isEnabled ? () {} : null,
                icon: const Icon(Icons.add),
                label: const Text('FilledButton'),
              ),
              FilledButton.tonalIcon(
                style: ElevatedButton.styleFrom(
                  iconSize: 30,
                  iconColor: Colors.red,
                  disabledIconColor: Colors.red.withValues(alpha: 0.5),
                ),
                onPressed: isEnabled ? () {} : null,
                icon: const Icon(Icons.add),
                label: const Text('Add'),
              ),
              OutlinedButton.icon(
                style: ElevatedButton.styleFrom(
                  iconSize: 30,
                  iconColor: Colors.red,
                  disabledIconColor: Colors.red.withValues(alpha: 0.5),
                ),
                onPressed: isEnabled ? () {} : null,
                icon: const Icon(Icons.add),
                label: const Text('OutlinedButton'),
              ),
              TextButton.icon(
                style: ElevatedButton.styleFrom(
                  iconSize: 30,
                  iconColor: Colors.red,
                  disabledIconColor: Colors.red.withValues(alpha: 0.5),
                ),
                onPressed: isEnabled ? () {} : null,
                icon: const Icon(Icons.add),
                label: const Text('TextButton'),
              ),
              SizedBox(
                width: 200,
                child: MenuItemButton(
                  style: MenuItemButton.styleFrom(
                    iconSize: 30,
                    iconColor: Colors.red,
                    disabledIconColor: Colors.red.withValues(alpha: 0.5),
                  ),
                  trailingIcon: const Icon(Icons.arrow_forward_ios),
                  onPressed: isEnabled ? () {} : null,
                  child: const Text('MenuItemButton'),
                ),
              ),
              SizedBox(
                width: 200,
                child: SubmenuButton(
                  style: SubmenuButton.styleFrom(
                    iconSize: 30,
                    iconColor: Colors.red,
                    disabledIconColor: Colors.red.withValues(alpha: 0.5),
                  ),
                  trailingIcon: const Icon(Icons.arrow_forward_ios),
                  menuChildren: <Widget>[
                    if (isEnabled) const Text('Item'),
                  ],
                  child: const Text('SubmenuButton'),
                ),
              ),
              SegmentedButton<Calendar>(
                style: SegmentedButton.styleFrom(
                  iconColor: Colors.red,
                  iconSize: 30,
                  disabledIconColor: Colors.red.withValues(alpha: 0.5),
                ),
                segments: const <ButtonSegment<Calendar>>[
                  ButtonSegment<Calendar>(
                      value: Calendar.day,
                      label: Text('Day'),
                      icon: Icon(Icons.calendar_view_day)),
                  ButtonSegment<Calendar>(
                      value: Calendar.week,
                      label: Text('Week'),
                      icon: Icon(Icons.calendar_view_week)),
                  ButtonSegment<Calendar>(
                      value: Calendar.month,
                      label: Text('Month'),
                      icon: Icon(Icons.calendar_view_month)),
                  ButtonSegment<Calendar>(
                      value: Calendar.year,
                      label: Text('Year'),
                      icon: Icon(Icons.calendar_today)),
                ],
                selected: <Calendar>{calendarView},
                onSelectionChanged:
                    isEnabled ? (Set<Calendar> newSelection) {} : null,
              )
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton.extended(
          onPressed: () {
            setState(() {
              isEnabled = !isEnabled;
            });
          },
          label: Text(isEnabled ? 'Enabled' : 'Disabled'),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[!] Flutter (Channel main, 3.25.0-1.0.pre.283, on macOS 15.0 24A5327a
    darwin-arm64, locale en-US)
    • Flutter version 3.25.0-1.0.pre.283 on channel main at
      /Users/tahatesser/Code/flutter
    ! Upstream repository [email protected]:TahaTesser/flutter.git is not the same
      as FLUTTER_GIT_URL
    • FLUTTER_GIT_URL = [email protected]:TahaTesser/flutter.gitexport
    • Framework revision aea84342eb (3 days ago), 2024-09-05 16:46:22 -0700
    • Engine revision 015f3b1dec
    • Dart version 3.6.0 (build 3.6.0-216.0.dev)
    • DevTools version 2.39.0
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/tahatesser/Code/android-sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_SDK_ROOT = /Users/tahatesser/Code/android-sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode-beta.app/Contents/Developer
    • Build 16A5230g
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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
      17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (4 available)
    • Taha’s iPhone (mobile)          • 00008120-001C559034DB401E • ios
      • iOS 18.0 22A5350a
    • macOS (desktop)                 • macos                     • darwin-arm64
      • macOS 15.0 24A5327a darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin
      • macOS 15.0 24A5327a darwin-arm64
    • Chrome (web)                    • chrome                    •
      web-javascript • Google Chrome 128.0.6613.120

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.found in release: 3.25Found to occur in 3.25frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions