From 0306c777ed56794e4120658af3ed5218d89d95d1 Mon Sep 17 00:00:00 2001 From: Sultan khan <> Date: Sun, 9 Jul 2023 10:54:28 +0300 Subject: [PATCH] rating bug fixed --- lib/extensions/string_extensions.dart | 3 ++- lib/widgets/new_design/doctor_header.dart | 28 +++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index e1700bc5..6ba96b08 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -1,6 +1,7 @@ extension CapExtension on String { + String get toCamelCase => "${this[0].toUpperCase()}${this.substring(1)}"; String get inCaps => '${this[0].toUpperCase()}${this.substring(1)}'; String get allInCaps => this.toUpperCase(); - String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.inCaps).join(" ") : ""; + String get capitalizeFirstofEach => this.trim().length > 0 ? this.trim().toLowerCase().split(" ").map((str) => str.isNotEmpty ? str.inCaps: str).join(" ") : ""; } diff --git a/lib/widgets/new_design/doctor_header.dart b/lib/widgets/new_design/doctor_header.dart index 2c9bb42a..bcbd55f8 100644 --- a/lib/widgets/new_design/doctor_header.dart +++ b/lib/widgets/new_design/doctor_header.dart @@ -298,12 +298,12 @@ class DoctorHeader extends StatelessWidget { width: 100.0, margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), child: Text(TranslationBase.of(context).excellent, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), - getRatingLine(doctorDetailsList[0].patientNumber, Colors.green[700]), + getRatingLine(doctorDetailsList[0].ratio, Colors.green[700]), ], ), Container( margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0), - child: Text(getRatingWidth(doctorDetailsList[0].patientNumber).round().toString() + "%", + child: Text(getRatingWidth(doctorDetailsList[0].ratio).round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), ), ], @@ -319,12 +319,12 @@ class DoctorHeader extends StatelessWidget { width: 100.0, margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), child: Text(TranslationBase.of(context).v_good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), - getRatingLine(doctorDetailsList[1].patientNumber, Color(0xffB7B723)), + getRatingLine(doctorDetailsList[1].ratio, Color(0xffB7B723)), ], ), Container( margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0), - child: Text(getRatingWidth(doctorDetailsList[1].patientNumber).round().toString() + "%", + child: Text(doctorDetailsList[1].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), ), ], @@ -340,12 +340,12 @@ class DoctorHeader extends StatelessWidget { width: 100.0, margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), child: Text(TranslationBase.of(context).good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), - getRatingLine(doctorDetailsList[2].patientNumber, Color(0xffEBA727)), + getRatingLine(doctorDetailsList[2].ratio, Color(0xffEBA727)), ], ), Container( margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0), - child: Text(getRatingWidth(doctorDetailsList[2].patientNumber).round().toString() + "%", + child: Text(doctorDetailsList[2].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), ), ], @@ -361,12 +361,12 @@ class DoctorHeader extends StatelessWidget { width: 100.0, margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), child: Text(TranslationBase.of(context).average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), - getRatingLine(doctorDetailsList[3].patientNumber, Color(0xffEB7227)), + getRatingLine(doctorDetailsList[3].ratio, Color(0xffEB7227)), ], ), Container( margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0), - child: Text(getRatingWidth(doctorDetailsList[3].patientNumber).round().toString() + "%", + child: Text(doctorDetailsList[3].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), ), ], @@ -383,12 +383,12 @@ class DoctorHeader extends StatelessWidget { width: 100.0, margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), child: Text(TranslationBase.of(context).below_average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), - getRatingLine(doctorDetailsList[4].patientNumber, Color(0xffE20C0C)), + getRatingLine(doctorDetailsList[4].ratio, Color(0xffE20C0C)), ], ), Container( margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0), - child: Text(getRatingWidth(doctorDetailsList[4].patientNumber).round().toString() + "%", + child: Text(doctorDetailsList[4].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)), ), ], @@ -410,12 +410,12 @@ class DoctorHeader extends StatelessWidget { pageBuilder: (context, animation1, animation2) {}); } - double getRatingWidth(int patientNumber) { - var width = (patientNumber / this.headerModel.totalReviews) * 100; + double getRatingWidth(double patientNumber) { + var width = patientNumber; return width.roundToDouble(); } - Widget getRatingLine(int patientNumber, Color color) { + Widget getRatingLine(double patientNumber, Color color) { return Container( margin: EdgeInsets.only(top: 10.0), child: Stack(children: [ @@ -427,7 +427,7 @@ class DoctorHeader extends StatelessWidget { ), ), SizedBox( - width: getRatingWidth(patientNumber) * 1.35, + width: patientNumber * 1.35, height: 4.0, child: Container( color: color,