Need your assistance.
I'm working on a flutter project using android studio. I'm finding it hard to display the Appbar when the bottom navigation bar is there. When I have them both, the appbar doesn't show when I run the app but when I remove the bottomnavbar, the Appbar becomes visible. How can I resolve this? This happens to all new dart files I create that I want to include an appbar.
I created a widget for the bottomnavbar on a different dart file. See code below: PS, Adding an appbar to this code below works well but not the other files where I vave a different appbar and calling the bottomnavbar like this: bottomNavigationBar: const BottomNavBar(),
import 'package:flutter/material.dart';
import 'package:salomon_bottom_bar/salomon_bottom_bar.dart';
import 'package:tikosocial/constants.dart';
class BottomNavBar extends StatefulWidget {
const BottomNavBar({super.key});
@override
State<BottomNavBar> createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
var currentIndex=0;
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: Container(
margin: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(.15),
blurRadius: 30,
offset: const Offset(0, 10),
),
],
borderRadius: BorderRadius.circular(50),
),
child: SalomonBottomBar(
currentIndex: currentIndex,
onTap: (i) => setState(() => currentIndex = i),
items: [
/// Home
SalomonBottomBarItem(
icon: const Icon(Icons.home_max_outlined),
title: const Text("Home"),
selectedColor: kHomeColor,
),
/// Ticket
SalomonBottomBarItem(
icon: const Icon(Icons.local_activity_outlined),
title: const Text("Ticket"),
selectedColor: kPrimaryColor,
),
/// Search
SalomonBottomBarItem(
icon: const Icon(Icons.search),
title: const Text("Search"),
selectedColor: kPrimaryColor,
),
/// Profile
SalomonBottomBarItem(
icon: const Icon(Icons.account_circle_rounded),
title: const Text("Account"),
selectedColor: kHomeColor,
),
],
),
),
);
}
}
But when I call it on a separate file only the bottomnavbar shows. See code sample below:
import 'package:flutter/material.dart';
import 'package:tikosocial/bottom_nav.dart';
class Home extends StatelessWidget {
const Home({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample Code'),
),
body: const Row(
),
bottomNavigationBar: const BottomNavBar(),
);
}
}