PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 8, 2022

[FIXED] How to set Divider in PopupMenuItem of flutter?

 November 08, 2022     dart, flutter, menu, user-interface     No comments   

Issue

I want to set divider between PopupMenuItem and I want to change styling PopupMenuDivider color which that have default color. How can i do this ?


Solution

You can do this very easily using the Theme class, using which you can change the icon color, text color and Default PopupMenuDivider color.

Again, you can easily do this on Divider at PopupMenuItem using PopupMenuDivider.

actions: [
      Theme(
        data: Theme.of(context).copyWith(
          dividerTheme: DividerThemeData(
            color: Colors.black,
          ),
          iconTheme: IconThemeData(color: Colors.white),
          textTheme: TextTheme().apply(bodyColor: Colors.white),
        ),
        child: PopupMenuButton<int>(
          color: Colors.indigo,
          //onSelected: (item) => onSelected(context, item),
          itemBuilder: (context) => [
            PopupMenuItem<int>(
              value: 0,
              child: Text('Settings'),
            ),
            PopupMenuDivider(),
            PopupMenuItem<int>(
              value: 1,
              child: Text('Share'),
            ),
            PopupMenuDivider(),
            PopupMenuItem<int>(
              value: 2,
              child: Row(
                children: [
                  Icon(Icons.logout),
                  const SizedBox(width: 8),
                  Text('Sign Out'),
                ],
              ),
            ),
          ],
        ),
      ),
    ],


Answered By - AL MAMUN
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing