Reputation: 168
I'm creating a Bottom Navigation Bar with Container. After applying Border Radius and Border to the container, there is this white color in the background which I'm trying to eliminate. I tried wrapping the outer Container with Colors.transparent
, yet the result remained unchanged.
How can I remove that white color in the background?
class BottomNavigationbar extends StatefulWidget {
@override
_BottomNavigationbarState createState() => _BottomNavigationbarState();
}
class _BottomNavigationbarState extends State<BottomNavigationbar> {
List<Widget> icons = [
Icon(
Icons.home,
color: Colors.black,
),
Icon(
Icons.person,
color: Colors.black,
),
Icon(
Icons.exit_to_app,
color: Colors.black,
)
];
List<Widget> pages = List.generate(3, (index) => Foo("Page : ${index + 1}"));
int currentIndex = 0;
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: icons.length,
child: Scaffold(
backgroundColor: Colors.transparent,
bottomNavigationBar: Container(
height: 55,
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Color(0xFFF38B6FF), width: 2),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20)),
color: Colors.transparent),
child: TabBar(
tabs: List.generate(
icons.length,
(int index) => Tab(
icon: icons[index],
)),
),
),
),
body: TabBarView(
children: [
new Container(
color: Colors.yellow,
),
new Container(
color: Colors.orange,
),
new Container(
color: Colors.lightGreen,
),
],
)),
);
}
}
class Foo extends StatelessWidget {
final String text;
Foo(this.text);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(text),
));
}
}
Upvotes: 1
Views: 2489
Reputation: 5423
Set extendBody
property of Scaffold
to true and set the navigationBar Container
color to white.
Scaffold(
extendBody: true,
//other code
)
and
BoxDecoration(
color: Colors.white,
border: Border.all(color: Color(0xFFF38B6FF), width: 2),
//other code
)
Upvotes: 4