Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add border Radius in the Inkwell widget in flutter

I want to add a hover color property to a container using the inkwell widget but the container has its own border-radius and when I am using the hover property using inkwell it is taking its custom shape and making it look rectangle in shape after hovering on the inkwell.

Here's my code snippet:

InkWell(
            
            onTap: () {},
            hoverColor: Colors.red[200],
            child: Container(
              width: 70.w,
              height: 60.h,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(20),
              ),
              child: Row(
                children: [
                  Image.asset(
                    'images/call.png',
                    height: 30.h,
                  ),
                  Text(
                    'Call',
                    style: white,
                  ),
                ],
              ),
            ),
          ),

I hope I made you understand the problem well

Please help me solve the issue or provide an alternate to it.

like image 219
Pratyay Sinha Avatar asked Oct 18 '20 07:10

Pratyay Sinha


People also ask

How do you get the InkWell border in Flutter?

To change the border of our splash to have a border-radius, we can the customBorder property of the InkWell widget. InkWell( customBorder: RoundedRectangleBorder( borderRadius: BorderRadius. circular(10), ), child: YourWidget(), ), The above code will control the flow of Splash to have a radius of 10 at all corners.

How do you add a border to a widget in Flutter?

Steps to add border to container in Flutter:Step 1: Go to the Container in which you want to add a border. Step 2: Add the decoration parameter and assign the BoxDecoration class. Inside the BoxDecoration add the parameter border and set it to Border. all().

How do you get border radius in container Flutter?

Flutter – Container Border Radius To set border radius for Container widget, set its decoration property with BoxDecoration where the borderRadius property is set with required value.


Video Answer


1 Answers

The Inkwell widget has a property customBorder of type ShapeBorder. You can use that to provide a borderRadius to your Inkwell.

E.g.:

customBorder: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(20),
),
like image 193
Matthias Avatar answered Oct 12 '22 22:10

Matthias