Add border Radius in the Inkwell widget in flutter - 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.

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),
),

The Inkwell widget has a property borderRadius of type BorderRadius
InkWell(
borderRadius: BorderRadius.circular(25),
// ...
);
OR
InkWell(
customBorder: CircleBorder(),
// ...
);

Simple and New Approach/Solution
I somehow agree with #Matthias's answer but if you need more realistic answer rather than giving RoundedRectangleBorder to customBorder property, then simply use CircleBorder() like an example below:
InkWell(customBorder: CircleBorder(), // ... );

InkWell(
borderRadius: BorderRadius.circular(12),
child: // ...
);

You can use the clip behavior to not have hard coded values when you have a widget that already has a border radius, eg a Card for example:
return Card(
clipBehavior: Clip.antiAlias,
child: InkWell(

To make splash also rounded, use suitable options of clipBehavior for Material widget.

Related

Flutter Material() in ListView builder decoration

How to change Material() border color i have this code, inkWell is a child of sliable widget that also returned in ListView.builder
child:InkWell(
onTap: (){
},
child: Material(
color: Colors.blueAccent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18),
),
child: buildListTile(item),
)
));
i need something like
also i can use only Material() class because my ListView.builder return me Sliable widget from Sliable library, and this is only widget i found that must work fine with desing that i wont
You can change the border of the Material widget using the side property inside your RoundedRectangleBorder.
I also typically put the InkWell inside the Material widget too.
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18),
side: const BorderSide(color: Colors.blueAccent),
),
child: InkWell(
borderRadius: BorderRadius.circular(18),
onTap: () {},
child: const ListTile(title: Text('item')),
),
),
),
You can use Card also try below code hope its help to you I have tried same as your image.
Card(
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.green.shade300),
borderRadius: BorderRadius.circular(15.0),
),
child: Column(
children: [
ListTile(
leading: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('OK'),
Text('OK'),
],
),
title: Text('name'),
),
],
),
),
Your result screen->

Flutter widget background not fill screen

I want to use a widget with a background color that only occupy a specific space without expanding for full screen. But, if I try this with Container it doesn't work like I want:
Container(
decoration: BoxDecoration(
color: AppColors.white.withOpacity(0.8),
borderRadius: BorderRadius.circular(24),
),
),
This code occupy the full screen, instead of only using the size it needs.
The idea is to show a Text and a Button in a Column, with a white background color. How can I accomplish this?
Actually I not really understand with your question, but you can wrap container inside container, and add padding in it. Or you can use stack to make your design more dynamic.
here is my code: maybe as you wish
SingleChildScrollView(
child: Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Colors.green
),
child: Container(
color: Colors.orange,
child: Column(
children: [
Text('Text 1'),
FlatButton(onPressed: (){}, child: Text("Button1"))
],
),
)
),
)
hope this can help you, thank you

Custom Container border in flutter

Hello friends I am new don't know how to make a custom border kindly help me to generate this type of border.
https://i.stack.imgur.com/MAlwG.png
Adding a border to a widget is very easy in Flutter. We just need to wrap the widget in a Container and add BoxDecoration to it.
Let’s say we want to make a square with blue borders all we need to do is:
Container(
height: 100,
width: 100,
decoration: BoxDecoration(
border: Border.all(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
child: Center(
child: Text('mrflutter.com'),
),
),
Also in the link there are other types
Source
Also there is a tutorial about BoxDecoration widget
Boxdecoration tutorial

Flutter ListTile splash/ripple effect not matching border

I have a ListTile in flutter but I cannot seem to figure out how to make the splash/ripple effect fit the border. My border is rounded, but the splash is just a normal rectangle with no round borders, as seen on the image below.
ListTile
Below is the code for the ListTile.
Ink(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
),
child: ListTile(
title: text(title, 0.0),
leading: Icon(
icon,
color: primaryColor,
),
)
)
You can use InkWell:
InkWell(
customBorder: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
onTap: () {},
splashColor: Colors.red,
child: ListTile(
title: Text("Title"),
),
),
Surround Ink or InkWell with ClipRRect with border-radius value equal to
BorderRadius.all(Radius.circular(borderRadius))
Better, replace Ink with InkWell and set borderRadius: BorderRadius.all(Radius.circular(borderRadius)) which won't need clipping.
thus you can write
InkWell(
borderRadius: BorderRadius.circular(borderRadius),
onTap: () {},
splashColor: Colors.red,
child: ListTile(
title: Text("Title"),
),
),

Flutter: how can I make a rounded PopupMenuButton's InkWell?

I have a PopupMenuButton inside a FloatingActionButton. But it's InkWell is not rounded, it is standard square shape. How can I achieve that?
Use customBorder property of InkWell:
InkWell(
customBorder: CircleBorder(),
onTap: () {}
child: ...
)
You can use borderRadius property of InkWell to get a rounded Ink Splash.
Material(
color: Colors.lightBlue,
borderRadius: BorderRadius.circular(25.0),
child: InkWell(
splashColor: Colors.blue,
borderRadius: BorderRadius.circular(25.0),
child: Text('Button'),
),
),
To change the InkWell's shape to rounded from standard square shape, Material's borderRadius property is used. Example code is given below -
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.green,
child: Material(
color: Colors.yellow,
borderRadius: BorderRadius.all(Radius.circular(5.0)),
child: InkWell(
child: PopupMenuButton(
//shape is used to change the shape of popup card
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.0)),
child: Icon(Icons.mode_edit, size: 22.0, color: Colors.red,),
itemBuilder: (context) => [
PopupMenuItem(
child: Text("Child 1"),
),
PopupMenuItem(
child: Text("Child 2"),
),
],
),
),
),
),
I faced a similar issue where the child of the PopupMenuButton would have a square InkWell around it.
In order to make it behave like an IconButton, which naturally uses the rounded InkWell, I simply had to use the icon paramater instead of the child.
icon: Icon(Icons.more_vert),
This is indicated in the documentation for that paramater:
/// If provided, the [icon] is used for this button
/// and the button will behave like an [IconButton].
final Widget icon;
Wrap the Inkwell with Material. Add Border Radius
Material(
borderRadius: BorderRadius.all( // add
Radius.circular(20)
),
child: InkWell(
child: Ink(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 10),
child: Text(
"Kayıt Ol",
style: TextStyle(
color: cKutuRengi,
),
),
),
),
)
Here's how to make the tap effect look right
Material(
borderRadius: BorderRadius.all(
Radius.circular(20)
),
child: InkWell(
customBorder:RoundedRectangleBorder( // add
borderRadius: BorderRadius.all(
Radius.circular(20)
)
),
onTap: () {
debugPrint("on tap");
},
child: Ink(
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 10),
child: Text(
"Kayıt Ol",
style: TextStyle(
color: cKutuRengi,
),
),
),
),
)
Most of the answers here are not using PopupMenuButton like the question specified. If you're simply using an icon child then you can use the icon property rather than child as already explained above, but if you want rounded corners on some other child, you wrap it with a Material, and wrap that with a ClipRRect See this Stackoverflow