I am making the booking and orders page and I want to create a container with a shadow in my Products tab . This is what I have right now and this is what I want to obtain:
Here it’s the code , should I do a widget? because if I add container I get a red line under .( also this happened with a SizedBox) Same I want to the orders tab .
class BookingOrdersScreen extends StatefulWidget {
const BookingOrdersScreen({super.key});
@override
State<BookingOrdersScreen> createState() => _BookingOrdersScreenState();
}
class _BookingOrdersScreenState extends State<BookingOrdersScreen>
with SingleTickerProviderStateMixin {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
Stream<QuerySnapshot<Map>>? stream;
late String currentUserID;
TabController? tabController;
@override
void initState() {
tabController = TabController(length: 3, vsync: this);
super.initState();
currentUserID = FirebaseAuth.instance.currentUser!.uid;
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: const Color.fromARGB(255, 255, 193, 59),
title: SizedBox(
width: 140,
height: 140,
),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
automaticallyImplyLeading: false),
body: SingleChildScrollView(
child: Column(
children: [
SizedBox(
height: MediaQuery.of(context).size.height /
1.5, // change it on your need
child: DefaultTabController(
length: 2,
child: Column(
children: [
SizedBox(
height: 10,
),
TabBar(
tabs: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.calendar_month,
color: const Color.fromARGB(255, 3, 59, 161),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.shopping_basket,
color: const Color.fromARGB(255, 3, 59, 161),
),
),
],
),
Expanded(
child: TabBarView(
controller: tabController,
children: const [
SizedBox(
height: 135,
width: 100,
),
Center(
child: Text(
'No orders made',
),
),
],
),
)
],
),
),
),
],
),
),
);
}
}
2
Answers
To create a container with a shadow in your Products tab, you can use a Container widget. The red line usually indicates a problem with the code or an unresolved issue. Let’s address that and show how to add a shadow to the container.
You can try this code may help.
Explanation:-
TabController
is initialized with the correct length, matching the number of tabs.Container
with shadow within the first tab of theTabBarView
. Thedecoration
property of theContainer
includes theBoxDecoration
withboxShadow
to achieve the shadow effect.TabBar
andTabBarView
to ensure correct display of tabs and their content.