Skip to content

styling PopupMenuDivider divider color #68176

Closed

Description

@pishguy

in this simple implementation code i added some PopupMenuButton items into AppBar actions argument and now i want to styling PopupMenuDivider color which that have default color.

i try to use ThemeData but i get error:

ThemeData(
  child: const PopupMenuDivider(
    height: 10,
  ),
),

my code:

PopupMenuButton<int>(
  onSelected: null,
  icon: const Icon(Icons.more_vert),
  color: const Color(0xFF32313C).withOpacity(0.9),
  elevation: 8.0,
  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)),
  itemBuilder: (context) {
    final list = <PopupMenuEntry<int>>[];
    list.add(
      PopupMenuItem(
        child: Row(
          children: [
            Icon(Icons.add, color: Colors.white),
            Text(
              "InduceSmile.com",
              style: TextStyle(color: Colors.white),
            ).pl(16.0),
          ],
        ),
      ),
    );
    list.add(
      const PopupMenuDivider(
        height: 10,
      ),
    );
    return list;
  },
offset: Offset(0, 100),
)

Activity

  1. pedromassangocode commented on Oct 15, 2020

    @pedromassangocode

    Hi @MahdiPishguy

    You can change the divider color by defining a dividerTheme in your app widget:

    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          title: 'Flutter Demo',
          theme: new ThemeData(
            primarySwatch: Colors.blue,
            dividerTheme: DividerThemeData( 
              color: Colors.red                                //  <--- change the divider's color
            )
          ),
        );
      }
    }

    Closing as this is not an issue with Flutter.
    Thank you

  2. pishguy commented on Oct 16, 2020

    @pishguy
    Author

    Hi @MahdiPishguy

    You can change the divider color by defining a dividerTheme in your app widget:

    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new MaterialApp(
          title: 'Flutter Demo',
          theme: new ThemeData(
            primarySwatch: Colors.blue,
            dividerTheme: DividerThemeData( 
              color: Colors.red                                //  <--- change the divider's color
            )
          ),
        );
      }
    }

    Closing as this is not an issue with Flutter.
    Thank you

    it doesn't good option, because of i want to change color while i need to have change that

  3. pedromassangocode commented on Oct 16, 2020

    @pedromassangocode

    Haa, you mean changing the color in the PopupMenuDivider itself.

  4. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    on Oct 16, 2020
  5. AriasBros commented on Jul 20, 2022

    @AriasBros

    I would need this too.

    Could I send a PR adding a color property to the PopupMenuDivider?

    class PopupMenuDivider extends PopupMenuEntry<Never> {
      ... ...
      final Color? color;
      ... ...
    }
    
    class _PopupMenuDividerState extends State<PopupMenuDivider> {
      @override
      Widget build(BuildContext context) => Divider(height: widget.height, color: widget.color);
    }
    

    Or is this approach rejected and the DividerThemeData is the preferred way by Flutter Team?

  6. added
    P3Issues that are less important to the Flutter project
    on Mar 17, 2025
  7. github-actions commented on Apr 17, 2025

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesteam-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