class PropertyDetailNavBar extends StatelessWidget {
const PropertyDetailNavBar({super.key});
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final loginBloc = context.read<LoginBloc>();
return BlocBuilder<PropertyDetailsCubit, PropertyDetailsState>(
builder: (context, state) {
if (state is PropertyDetailsLoaded) {
final agent = state.singlePropertyModel.propertyAgent;
if (agent == null) {
return const SizedBox.shrink();
}
return Container(
width: size.width,
height: 190.0,
padding: const EdgeInsets.only(bottom: 5.0),
decoration: const BoxDecoration(
color: primaryColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(20.0),
topLeft: Radius.circular(20.0),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20.0, vertical: 14.0)
.copyWith(top: 4.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipOval(
child: CustomImage(
path: RemoteUrls.imageUrl(agent.image),
height: size.height * 0.08,
width: size.height * 0.08,
fit: BoxFit.cover,
),
),
const SizedBox(width: 10.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomTextStyle(
text: agent.name,
fontSize: 20.0,
fontWeight: FontWeight.w600,
color: whiteColor,
),
CustomTextStyle(
text: agent.designation,
fontSize: 14.0,
fontWeight: FontWeight.w400,
color: whiteColor,
),
],
),
),
const Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
CustomTextStyle(
text: "Contact Us",
fontSize: 16.0,
fontWeight: FontWeight.w400,
color: whiteColor,
),
CustomTextStyle(
text: '+8801977663736',
fontSize: 16.0,
fontWeight: FontWeight.w400,
color: whiteColor,
),
],
),
],
),
),
const SizedBox(height: 10.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Flexible(
child: ContactButton(
onPressed: () {
if (loginBloc.userInfo != null &&
loginBloc.userInfo!.accessToken.isNotEmpty) {
Navigator.pushNamed(
context, RouteNames.sendMessageScreen,
arguments: agent.email);
} else {
Utils.showSnackBarWithLogin(context);
}
},
bgColor: yellowColor,
text: 'Message',
icon: KImages.messageIcon,
iconTextColor: blackColor,
),
),
const SizedBox(width: 10.0),
Flexible(
child: ContactButton(
onPressed: () async {
if (loginBloc.userInfo != null &&
loginBloc.userInfo!.accessToken.isNotEmpty) {
Uri uri = Uri(scheme: 'tel', path: agent.phone);
//print(uri.runtimeType);
if (agent.phone.isNotEmpty) {
launchUrl(uri);
} else {
Utils.showSnackBar(
context, 'Phone number is Empty');
}
} else {
Utils.showSnackBarWithLogin(context);
}
},
bgColor: blackColor,
text: 'Call',
icon: KImages.callIcon,
iconTextColor: whiteColor,
),
),
],
),
],
),
);
}
return const SizedBox.shrink();
},
);
}
}
I copied the call code from another dart file where it is working perfectly. But when I put it here it is telling me that the number is empty. It should be pulling data from the agent’s profile. When I directly go to their profile and press the call button it works.
When I press the call button it should open the phone app with the agent number on it.