I need to make the following tab bar (Upcoming/Past) view but not able to achieve it.
Here is the code:
import 'package:cali_clinic/helpers/app_exports/app_exports.dart';
import 'package:cali_clinic/reuseables/widgets/app_bar/common_app_bars.dart';
import 'package:cali_clinic/screens/appointment_screen/model/apponitment_screen_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_svg/svg.dart';
import '../../../helpers/constants/brand_color.dart';
import '../../../helpers/constants/image_contants.dart';
import '../../../reuseables/widgets/text_fields.dart/search_appointment_field.dart';
import '../../../reuseables/widgets/text_fields.dart/search_text_field.dart';
import '../../../reuseables/widgets/text_widget/display_text.dart';
import '../vm/appointment_screen_vm.dart';
class AppointmentScreen extends StatefulWidget {
AppointmentScreen({super.key});
@override
State<AppointmentScreen> createState() => _AppointmentScreenState();
}
class _AppointmentScreenState extends State<AppointmentScreen>
with SingleTickerProviderStateMixin {
late TabController tabController;
Color upComing = const Color(0xFF00509D);
@override
void initState() {
tabController = TabController(length: 2, vsync: this);
super.initState();
}
late final AppointmentScreenVM _apppointmentScreenVM = AppointmentScreenVM();
@override
Widget build(BuildContext context) {
double fem = MediaQuery.of(context).size.width / 428;
double ffem = fem * 0.97;
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Column(
children: [
SizedBox(
height: 60 * ffem,
child: Row(
children: [
Expanded(
child: Container(
decoration: ShapeDecoration(
color: ColorConstant.blackColor,
shape: RoundedRectangleBorder(
side: const BorderSide(
width: 1, color: Color(0xFFF4F4F5)),
borderRadius: BorderRadius.circular(8),
),
),
),
),
Expanded(
child: Container(
color: ColorConstant.blueGray50,
),
),
],
)),
Padding(
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
flex: 10,
child: SizedBox(
height: 36 * ffem,
width: 300,
child: searchAppointmentField()),
),
const Expanded(flex: 1, child: SizedBox()),
Expanded(
flex: 1,
child: Container(
height: 36 * ffem,
width: 36 * ffem,
padding: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: ColorConstant.gray50, // Background color
borderRadius: BorderRadius.circular(
10.0), // Optional: border radius
),
child: SvgPicture.asset(
ImageConstant.filterSvg,
),
),
)
],
),
),
Expanded(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
ImageConstant.emptySvg,
),
SizedBox(
height: 16 * ffem,
),
const DisplayText(
text: 'No Data Found',
),
],
),
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your FAB onPressed functionality here
},
shape: const CircleBorder(), // Make the FAB circular
backgroundColor: ColorConstant.darkBlue,
child: const Icon(
Icons.add,
color: ColorConstant.whiteColor,
),
),
);
}
}
This is the view I want to achieve
This I where I am currently
2
Answers
Try below code hope its help to you. I have paste Only UI Code that includes Tab bar and UI.
UI:
Try this code, it think it’s close enough for what you need. I have also made tab color transition animation when swiping tabs.