Dipta Das
Dipta Das

Reputation: 3

how to make child widget looks like its bigger then its parent widget in flutter

I want to make a custom navigationbar widget in Flutter. The blue circle widget size is bigger than its parent widget. But I don't know how to make it without any plugins. Please see the image for clarification.

enter image description here

Upvotes: 0

Views: 1056

Answers (2)

David Miguel
David Miguel

Reputation: 14470

enter image description here

class CustomNavBar extends StatelessWidget {
  const CustomNavBar({final super.key});

  @override
  Widget build(final BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        Container(
          decoration: const BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(16)),
          ),
          padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
          width: 150,
          child: Row(
            children: [
              GestureDetector(
                child: const Icon(
                  Icons.phone,
                  color: Color(0xFF24A3FF),
                ),
                onTap: () {
                  // On phone tapped
                },
              ),
              const Spacer(),
              GestureDetector(
                child: const Icon(
                  Icons.contacts,
                  color: Color(0xFF24A3FF),
                ),
                onTap: () {
                  // On contacts tapped
                },
              ),
            ],
          ),
        ),
        GestureDetector(
          child: Container(
            height: 50,
            width: 50,
            decoration: BoxDecoration(
              color: Colors.white,
              shape: BoxShape.circle,
              border: Border.all(color: Color(0xFF24A3FF), width: 6),
            ),
            child: Icon(UniconsLine.plus, color: Color(0xFF24A3FF)),
          ),
          onTap: () {
            // On plus tapped
          },
        ),
      ],
    );
  }
}

Upvotes: 1

Kaushik Chandru
Kaushik Chandru

Reputation: 17812

You can use a Stack to achieve this effect

SizedBox(
  height: 70,
  width: MediaQuery.of(context).size.width *0.7,
child :Stack(
 children: [
 Center(
  child : Container(
   height : 40,
  width : MediaQuery.of(context).size.width * 0.7,
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(10),
     color : Colors.red,
    )
   child: Row(
     children : [
       Icon(Icons.add),
       Container(),
      Icon(Icons.remove),
     ]
   )
  ),
  ),
 Center(
  child: CircleAvatar(
   radius : 70,
   
  )
  )
 ]
)
)

Upvotes: 0

Related Questions