Flutter Navbar UI Border Radius - android

I am currently working on my first mobile app, and need some help with some of the code pertaining to my navbar. I have watched some videos and read some docs on using the tag BottomNavigationBar to better sort and make my navigation bar but I am struggling to make it look how I want. Right now I have the default navbar it gives you with a different background color but I added padding to give it space from the edges of the screen. I now want to round the corners but it seems wherever I try to apply a border-radius it just doesn't work. Any idea how I can go about rounding these corners to give a good-looking floating navbar look? Thanks!
Current Navbar Look
Widget build(BuildContext context) {
return Scaffold(
// ignore: prefer_const_literals_to_create_immutables
bottomNavigationBar: Container(
padding: const EdgeInsets.all(8.0),
child: Material(
borderRadius: BorderRadius.circular(10),
color: Colors.black,
child: BottomNavigationBar(
fixedColor: Colors.white,
unselectedItemColor: Colors.white,
backgroundColor: Color.fromARGB(255, 27, 27, 27),
currentIndex: _selectedIndex,
// ignore: prefer_const_literals_to_create_immutables
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.add), label: 'Add Friend'),
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Search Friends'),
],
),
),
),
);
}

Related

How to increase the overall thickness of a banner in flutter?

I'm making a flutter app where there's a gridview of cards that shows details of different items in a list. In the top right corner of the card I added a banner using the banner widget that shows the current status of the item.
This is what the banner looks like. But I want to move the banner a bit more to the corner as well as make it more wider.
Card(
elevation: 1.0,
child: ClipRect(
child: Banner(
textStyle: TextStyle(color: Colors.white),
message: 'OPEN'
location: BannerLocation.topEnd,
color: const Color(0xFF0db3ae),
child: InkWell(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('......')
),
onTap: () {},
),
),
),
);
This is the basic structure of the code I used to make the cards and to make sure the banner wraps around the card. But i can't find a way to increase it's width or move it a bit more to the corner.

flutter Remove background color from Floating Action Button

I am using an image as a child of the floating action button on flutter. I don't need any background color.
and also I need to make the image size bigger. how can I do this? help, please.
Simply do this:
FloatingActionButton(
backgroundColor: Colors.transparent,
)
Edit: My answer is just a workaround. backgroundColor: Colors.transparent goes well.
I think for your case, you can also try workaround like this,
floatingActionButton: GestureDetector(
onTap: () {
// Do Something
},
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage("https://www.dartpad.dev/dart-192.png")),
borderRadius: BorderRadius.circular(0.50),
),
width: 50.0,
height: 50.0,
),
),
Play with height and width values for desired result. You can also add boxShadow to Container to look like the actual FAB.
Refer: https://api.flutter.dev/flutter/painting/BoxDecoration-class.html
and also for including your image from asset, refer https://api.flutter.dev/flutter/painting/DecorationImage-class.html
Hope that suits your case!
Colors.transparent
Will remove the color from any widget which accepts color parameter. Please use it in your FloatingActionButton like below:
FloatingActionButton(
elevation: 0.0,
child: new Icon(Icons.check),
backgroundColor: Colors.transparent,
onPressed: (){}
)

Why there is a difference in BottomAppBar height on android and ios with flutter?

I have implemented a bottom app bar in a flutter app, but the height in both the devices are different and even the margin also.
main.dart
bottomNavigationBar: BottomAppBar(
color: Colors.black,
child: IconButton(
onPressed: () {},
icon: Icon(
Icons.fiber_manual_record,
color: Colors.white,
),
),
),

Flutter: How to make some area of image transparent in Flutter?

I want the lower path of Doctor image to get transparent so that I can see the tiles going underneath it.
How can I do that? I tried opacity but it is making the whole image fade.
Remember just the lower part not whole image
For different opacity in the same image, you can use a ShaderMask like this:
ShaderMask(
shaderCallback: (rect) {
return LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[
Colors.black.withOpacity(1.0),
Colors.black.withOpacity(1.0),
Colors.black.withOpacity(0.3),
Colors.black.withOpacity(0.3),// <-- change this opacity
// Colors.transparent // <-- you might need this if you want full transparency at the edge
],
stops: [0.0, 0.5,0.55, 1.0], //<-- the gradient is interpolated, and these are where the colors above go into effect (that's why there are two colors repeated)
).createShader(Rect.fromLTRB(0, 0, rect.width, rect.height));
},
blendMode: BlendMode.dstIn,
child: FlutterLogo(size: 80, colors: Colors.red),
),
You'll have to play around with the LinearGradient stops in order to get the effect that you're looking for. Just for completeness sake, let me explain the colors and the stops that I chose. Since the gradient is interpolated, you need a really strong step from one color to the other. So, looking at the stops and colors, it reads like this:
start the first color (with opacity = 1.0) at 0% of the way down and go until you hit 50% of the way down, then interpolate from 50% to 55% from opacity 1.0 to opacity 0.3 (that's why those numbers need to be close together) Finally, end with opacity 0.3 at 100% of the image.
I explained that piece, because you will have to adjust the 0.5 and 0.55 piece to make it look how you want.
You will have to use Stack and positioned widget side by side.
Add your image as child of the Container. I hope this helps
Stack(
children: <Widget>[
Positioned(
right: 20,
child: Container(
height: 150,
width: 100,
color: Colors.black,
),
),
ListView(
padding: EdgeInsets.only(top: 100),
children: <Widget>[
Ink(
color: Colors.green,
child: ListTile(
title: Text("Tile 1"),
subtitle: Text("subtitle"),
),
),
Ink(
color: Colors.blue,
child: ListTile(
title: Text("Tile 2"),
subtitle: Text("subtitle"),
),
),
Ink(
color: Colors.green,
child: ListTile(
title: Text("Tile 3"),
subtitle: Text("subtitle"),
),
),
],
),
],
),

How do I set the background colour/image to be stacked above another expanded widget? Or is there another way

Currently the only way I could make this kind of curved effect would be through making 2 container, making 1 a child of another and making 1 container's colour into the background colour.
However I cannot replicate this effect if the background is an image. Could anyone assist?
Example of the code I use:
Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
Container(
height: 100,
color: Color(0xFF0D6068),
),
Expanded(
child: Container(
color: Color(0xFF0D6068),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
)),
),
))
],
)),
);
You can make use of a Stack widget to achieve this, such that the background color or image would be at the back then the curved container would be stacked on it. Here is an example code.
Stack(children <Widget> [
Image.asset(''),
Container()
]
)
Instead of using an image asset, you can make use of BoxDecoration with the decoration parameter of a container. The BoxDecoration has an image parameter where you can provide your image with a DecorationImage() widget.

Categories

Resources