charts tab and bug fix added

This commit is contained in:
venbaittech 2025-01-21 12:29:31 +05:30
parent dceda7c568
commit a2eadb0a8a
10 changed files with 877 additions and 351 deletions

View File

@ -366,14 +366,20 @@ final GoRouter router = GoRouter(
// Retrieve query parameter
final bgColor = state.uri.queryParameters['bgColor'] ??
'0xFFFFFFFF'; // Default white
final mainTopic = state.uri.queryParameters['mainTopic'] ?? '';
final title = state.uri.queryParameters['title'] ?? '';
print('Router dataSets: $dataSets');
print('Router bgColor: $bgColor');
print('Router mainTopic: $mainTopic');
print('Router title: $title');
// Pass both values to the screen
return ChartScreen1(
dataSets: dataSets,
bgColor: bgColor,
mainTopic: mainTopic,
title: title,
);
},
),

View File

@ -102,12 +102,8 @@ class _UaenumberWidgetState extends State<uaenumberWidget> {
isExpanded: isFirstTile,
title: mainTopic['main_topic'],
titleBackgroundColor: backgroundColor,
children: _buildSubTopics(
mainTopic['sub_topics'] ?? [],
mywidth,
borderColor,
colorPattern,
),
children: _buildSubTopics(mainTopic['sub_topics'] ?? [], mywidth,
borderColor, colorPattern, mainTopic['main_topic']),
);
}),
],
@ -116,7 +112,7 @@ class _UaenumberWidgetState extends State<uaenumberWidget> {
}
List<Widget> _buildSubTopics(List<dynamic> subTopics, double myWidth,
Color borderColor, String colorPattern) {
Color borderColor, String colorPattern, mainTopic) {
print('colorPattern123 $borderColor');
// Sort sub-topics based on `sub_topic_list_order`
subTopics.sort((a, b) => (a['sub_topic_list_order'] ?? 0)
@ -128,14 +124,14 @@ class _UaenumberWidgetState extends State<uaenumberWidget> {
children: [
buildCategoryTitle(subTopic['sub_topic'], borderColor),
..._buildDataSetCards(subTopic['tile_data'] ?? [], myWidth,
borderColor, colorPattern),
borderColor, colorPattern, mainTopic),
],
))
.toList();
}
List<Widget> _buildDataSetCards(
List<dynamic> tileData, double myWidth, Color borderColor, colorPattern) {
List<Widget> _buildDataSetCards(List<dynamic> tileData, double myWidth,
Color borderColor, colorPattern, mainTopic) {
// Sort datasets based on `data_set_list_order`
tileData.sort((a, b) => (a['data_set_list_order'] ?? 0)
.compareTo(b['data_set_list_order'] ?? 0));
@ -162,16 +158,17 @@ class _UaenumberWidgetState extends State<uaenumberWidget> {
padding:
const EdgeInsets.symmetric(horizontal: 5.0), // Add spacing
child: buildCard(
context,
data['data_set_tile_heading'] ?? '',
data['value'] ?? '',
data['value_source'] ?? '',
data['data_set'] ?? '',
borderColor,
borderColor,
colorPattern,
cardWidth, // Pass the calculated width
),
context,
data['data_set_tile_heading'] ?? '',
data['value'] ?? '',
data['value_source'] ?? '',
data['data_set'] ?? '',
borderColor,
borderColor,
colorPattern,
cardWidth,
mainTopic // Pass the calculated width
),
),
);
}).toList(),
@ -211,20 +208,29 @@ class _UaenumberWidgetState extends State<uaenumberWidget> {
}
Widget buildCard(
BuildContext context,
String title,
String value,
String subtitle,
String data_set,
Color bordercolor,
Color boldColor,
colorPattern,
double mywidth,
) {
BuildContext context,
String title,
String value,
String subtitle,
String data_set,
Color bordercolor,
Color boldColor,
colorPattern,
double mywidth,
String mainTopic) {
return GestureDetector(
onTap: () {
print(colorPattern);
context.go('/chartScreen/$data_set?bgColor=$colorPattern');
// print('checking data');
// print(mainTopic);
// print(title);
// print(subtitle);
// print(data_set);
final encodedMainTopic = Uri.encodeComponent(mainTopic);
final encodedTitle = Uri.encodeComponent(title);
// Pass mainTopic and title as query parameters
context.go(
'/chartScreen/$data_set?bgColor=$colorPattern&mainTopic=$encodedMainTopic&title=$encodedTitle');
// context.go('/chartScreen/$data_set');
},
child: Card(

View File

@ -297,15 +297,16 @@ class _RegisterScreenState extends State<RegisterScreen> {
Consumer(
builder: (context, ref, _) {
final locale = ref.watch(localeProvider); // Current locale
return
MyToggle(isOn: locale?.languageCode == 'en',
knobTextWhenOn: 'ع',
knobTextWhenOff: 'EN',
pathColorWhenOn: Colors.grey.shade300,
pathColorWhenOff: Colors.grey.shade300,
onTap: (){
ref.read(localeProvider.notifier).toggleLocale();
},);
return MyToggle(
isOn: locale?.languageCode == 'en',
knobTextWhenOn: 'ع',
knobTextWhenOff: 'EN',
pathColorWhenOn: Colors.grey.shade300,
pathColorWhenOff: Colors.grey.shade300,
onTap: () {
ref.read(localeProvider.notifier).toggleLocale();
},
);
// IconButton(
// icon: Icon(locale?.languageCode == 'en'
// ? Icons.toggle_off_outlined
@ -329,7 +330,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
buildIconContainer(Icons.report, Color(0xFF7DAFBC)),
SizedBox(height: 20),
Text(
"Your registration is pending for Admin Approval.",
"Your registration is pending for verification.",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
@ -338,7 +339,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
),
SizedBox(height: 10),
Text(
"Access will be granted once your account is approved.",
"Kindly verify your mail to proceed further.",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
@ -452,7 +453,9 @@ class _RegisterScreenState extends State<RegisterScreen> {
focusNode: _focusNodes[0],
decoration: InputDecoration(
// hintText: _showHints[0] ? 'Username' : null,
hintText: _showHints[0] ? AppLocalizations.of(context)!.register_name : null,
hintText: _showHints[0]
? AppLocalizations.of(context)!.register_name
: null,
prefixIcon: Icon(
Icons.person,
color: Colors.blue,
@ -471,8 +474,9 @@ class _RegisterScreenState extends State<RegisterScreen> {
focusNode: _focusNodes[1],
decoration: InputDecoration(
// hintText: 'Enter your email',
hintText:
_showHints[1] ? AppLocalizations.of(context)!.register_email : null,
hintText: _showHints[1]
? AppLocalizations.of(context)!.register_email
: null,
// _showHints[1] ? 'Enter your email' : null,
prefixIcon: Icon(
Icons.email,
@ -495,8 +499,10 @@ class _RegisterScreenState extends State<RegisterScreen> {
focusNode: _focusNodes[2],
obscureText: _obscurePassword,
decoration: InputDecoration(
hintText:
_showHints[2] ? AppLocalizations.of(context)!.register_password : null,
hintText: _showHints[2]
? AppLocalizations.of(context)!
.register_password
: null,
// _showHints[2] ? 'Enter your password' : null,
prefixIcon: Icon(
Icons.lock,
@ -528,8 +534,10 @@ class _RegisterScreenState extends State<RegisterScreen> {
focusNode: _focusNodes[3],
obscureText: _obscureConfirmPassword,
decoration: InputDecoration(
hintText:
_showHints[3] ? AppLocalizations.of(context)!.register_Confirm_password : null,
hintText: _showHints[3]
? AppLocalizations.of(context)!
.register_Confirm_password
: null,
// _showHints[3] ? 'Confirm password' : null,
prefixIcon: Icon(
Icons.lock,
@ -583,16 +591,22 @@ class _RegisterScreenState extends State<RegisterScreen> {
// text: 'I agree to ',
children: [
TextSpan(
text: AppLocalizations.of(context)!.terms_conditions,
text: AppLocalizations.of(context)!
.terms_conditions,
// text: 'Terms & Conditions',
style: TextStyle(color: Colors.blue),
),
TextSpan(text: AppLocalizations.of(context)!.t_and),
TextSpan(
text: AppLocalizations.of(context)!.privacy_policy,
text: AppLocalizations.of(context)!
.t_and),
TextSpan(
text: AppLocalizations.of(context)!
.privacy_policy,
style: TextStyle(color: Colors.blue),
),
TextSpan(text: AppLocalizations.of(context)!.conditions),
TextSpan(
text: AppLocalizations.of(context)!
.conditions),
],
),
),
@ -632,7 +646,8 @@ class _RegisterScreenState extends State<RegisterScreen> {
children: [
Text(
// "Register",
AppLocalizations.of(context)!.register_title,
AppLocalizations.of(context)!
.register_title,
style: TextStyle(
fontSize: 16, color: Colors.white),
),

View File

@ -8,9 +8,16 @@ import '../filters/search_filter_helper.dart';
class ChartScreen1 extends StatefulWidget {
final String dataSets;
final String bgColor;
final String mainTopic;
final String title;
const ChartScreen1(
{Key? key, required this.dataSets, required String this.bgColor});
const ChartScreen1({
Key? key,
required this.dataSets,
required String this.bgColor,
required this.mainTopic,
required this.title,
});
@override
_ChartScreen1State createState() => _ChartScreen1State();
}
@ -24,17 +31,89 @@ class _ChartScreen1State extends State<ChartScreen1> {
List<dynamic> nonChartData = [];
List<dynamic> filterData = [];
List<dynamic> chartsData = [];
List<dynamic> tabFilteredChartData = [];
List<dynamic> tabFilteredCardData = [];
List<dynamic> cardData = [];
List<dynamic> originalChartsData = [];
List<dynamic> originalCardData = [];
List<dynamic> originalTabCardData = [];
List<dynamic> originalTabChartsData = [];
late Color backgroundColor;
final ScrollController _scrollController = ScrollController();
int _activeTabIndex = 0;
dynamic _tabsData = [];
@override
void initState() {
super.initState();
final String bgColor = widget.bgColor;
print(' bgColor $bgColor');
fetchChartData(widget.dataSets);
// fetchChartData(widget.dataSets);
fetchChartData(widget.dataSets).then((_) {
if (_tabsData.isNotEmpty) {
// Call onTabSelected for the first tab
onTabSelected(_tabsData[0]['id']);
}
});
}
void _scrollToIndex(int index) {
double scrollPosition = index * 120.0; // Adjust based on tab size
_scrollController.animateTo(
scrollPosition,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
void _scrollLeft() {
if (_activeTabIndex > 0) {
setState(() {
_activeTabIndex--;
});
_scrollToIndex(_activeTabIndex);
onTabSelected(_tabsData[_activeTabIndex]['id']!); // Pass the tab's id
}
}
void _scrollRight() {
if (_activeTabIndex < _tabsData.length - 1) {
setState(() {
_activeTabIndex++;
});
_scrollToIndex(_activeTabIndex);
onTabSelected(_tabsData[_activeTabIndex]['id']!); // Pass the tab's id
}
}
void processChartData(chartsData) {
// Group data by 'kpi'
Map<String, List<Map<String, dynamic>>> groupedData = {};
for (var chart in chartsData) {
String kpi = chart['kpi'] ?? '';
if (!groupedData.containsKey(kpi)) {
groupedData[kpi] = [];
}
groupedData[kpi]!.add(chart);
}
// Format 'kpi' values for _tabs
List<Map<String, String>> _tabs = groupedData.keys.map((kpi) {
String name = kpi
.split('_') // Split by underscore
.map(
(word) => word[0].toUpperCase() + word.substring(1)) // Capitalize
.join(' '); // Join words with space
return {'id': kpi, 'name': name};
}).toList();
print('Grouped Data: $groupedData');
print('Tabs: $_tabs');
setState(() {
_tabsData = _tabs;
});
}
Future<void> fetchChartData(String dataSets) async {
@ -49,6 +128,9 @@ class _ChartScreen1State extends State<ChartScreen1> {
chartsData = isChartData;
cardData = nonChartData;
processChartData(chartsData);
print('chartsData :- $chartsData');
print('cardData :- $cardData');
print('filterData :- $filterData');
@ -64,8 +146,9 @@ class _ChartScreen1State extends State<ChartScreen1> {
// Check if all filter_data is empty
if (selectedFilters.every((filter) => filter['filter_data'].isEmpty)) {
setState(() {
chartsData = List.from(originalChartsData); // Restore the original data
cardData = List.from(originalCardData); // Restore the original data
chartsData =
List.from(originalTabChartsData); // Restore the original data
cardData = List.from(originalTabCardData); // Restore the original data
});
print('Returning as no filters are selected');
Navigator.pop(context);
@ -151,6 +234,14 @@ class _ChartScreen1State extends State<ChartScreen1> {
Navigator.pop(context);
}
String capitalizeAndSplit(String text) {
if (text.isEmpty) return text;
return text
.split('_') // Split by underscores
.map((word) => word[0].toUpperCase() + word.substring(1).toLowerCase())
.join(' '); // Join words with a space
}
void showRightSideModal(BuildContext context, List filters, List data) {
// Initialize selected filters structure from the stored value, if exists
List<Map<String, dynamic>> selectedFilters =
@ -215,7 +306,7 @@ class _ChartScreen1State extends State<ChartScreen1> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
filterKey,
capitalizeAndSplit(filterKey),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
@ -330,8 +421,8 @@ class _ChartScreen1State extends State<ChartScreen1> {
filter["filter_data"].clear();
});
setState(() {
chartsData = List.from(originalChartsData);
cardData = List.from(originalCardData);
chartsData = List.from(originalTabChartsData);
cardData = List.from(originalTabCardData);
});
// Reset the selectedFiltersStorage to empty when clearing
selectedFiltersStorage.clear();
@ -347,8 +438,8 @@ class _ChartScreen1State extends State<ChartScreen1> {
print(
"Selected Filters before applying: $selectedFilters");
setState(() {
chartsData = originalChartsData;
cardData = originalCardData;
chartsData = originalTabChartsData;
cardData = originalTabCardData;
});
applyFilters(context, filters, chartsData, cardData,
@ -372,8 +463,68 @@ class _ChartScreen1State extends State<ChartScreen1> {
);
}
void onTabSelected(String tabId) {
print('Selected Tab: $tabId');
selectedFiltersStorage.clear();
setState(() {
chartsData = originalChartsData;
cardData = originalCardData;
});
performActionForTab(tabId);
}
void performActionForTab(String tabId) {
print('Selected Tab: $tabId');
// Filter the chartsData array based on the tabId
tabFilteredChartData = chartsData.where((chart) {
// Assuming each chart item has a 'kpi' field that matches tabId
return chart['kpi'] == tabId;
}).toList(); // Convert to list after filtering
print('tabFilteredChartData Data for Tab $tabId: $tabFilteredChartData');
setState(() {
chartsData = tabFilteredChartData;
originalTabChartsData =
List.from(tabFilteredChartData); // Store original data
});
// Filter the chartsData array based on the tabId
tabFilteredCardData = cardData.where((chart) {
// Assuming each chart item has a 'kpi' field that matches tabId
return chart['kpi'] == tabId;
}).toList(); // Convert to list after filtering
print('tabFilteredCardData Data for Tab $tabId: $tabFilteredCardData');
setState(() {
cardData = tabFilteredCardData;
originalTabCardData = List.from(tabFilteredCardData);
});
// You can perform further actions with the filteredData, like updating the UI
// For example, you can update the chart data or display the results
}
double calculateAspectRatio(int itemCount) {
// Modify the logic based on your layout requirements
if (itemCount <= 2) {
return 190.5 / 180;
} else if (itemCount == 3) {
return 180.0 / 300;
} else if (itemCount == 4) {
return 190.5 / 180;
} else {
return 180.0 / 260; // Default for more items
// return 190.5 / 180;
}
}
@override
Widget build(BuildContext context) {
double myheight = MediaQuery.of(context).size.height;
double mywidth = MediaQuery.of(context).size.width;
final color =
Color(int.parse(widget.bgColor.replaceFirst('0x', ''), radix: 16));
return Scaffold(
@ -385,7 +536,7 @@ class _ChartScreen1State extends State<ChartScreen1> {
leading: IconButton(
icon: Icon(Icons.arrow_back_ios_new, color: Colors.white),
onPressed: () {
context.go('/myhomepage');
context.go('/uaenumbers');
},
),
title: Text(
@ -397,6 +548,55 @@ class _ChartScreen1State extends State<ChartScreen1> {
? Center(child: CircularProgressIndicator())
: Column(
children: [
Container(
// height: myheight / 5,
width: double.infinity,
color: color,
child: Padding(
padding: EdgeInsets.only(
left: 30, right: 30, top: 10, bottom: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.mainTopic ?? '',
style: TextStyle(
color: Colors.white,
fontSize: 26,
),
),
Container(
width: mywidth / 4,
child: Divider(
thickness: 8,
color: Colors.white,
)),
Text(
widget.title,
style: TextStyle(color: Colors.white, fontSize: 20),
),
// Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// IconButton(
// onPressed: () {},
// icon: Icon(
// Icons.bookmark_add_outlined,
// color: Colors.white,
// size: 40,
// )),
// IconButton(
// onPressed: () {},
// icon: Icon(
// Icons.share,
// color: Colors.white,
// size: 30,
// )),
// ],
// ),
],
),
)),
Expanded(
child: ListView(
children: [
@ -404,8 +604,7 @@ class _ChartScreen1State extends State<ChartScreen1> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
mainAxisAlignment: MainAxisAlignment
.end, // Aligns the row's content to the right
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
children: [
@ -416,12 +615,12 @@ class _ChartScreen1State extends State<ChartScreen1> {
color: Colors.white,
),
),
SizedBox(width: 5),
Icon(Icons.bookmark_add_outlined,
color: Colors.white, size: 18),
],
),
SizedBox(
width: 10), // Horizontal space between items
SizedBox(width: 10),
Row(
children: [
Text(
@ -431,15 +630,16 @@ class _ChartScreen1State extends State<ChartScreen1> {
color: Colors.white,
),
),
SizedBox(width: 5),
Icon(Icons.share_sharp,
color: Colors.white, size: 18),
],
),
SizedBox(
width: 10), // Horizontal space between items
width: 5), // Horizontal space between items
IconButton(
icon: Icon(Icons.filter_alt_outlined,
color: Colors.white, size: 18),
color: Colors.white, size: 28),
onPressed: () {
showRightSideModal(
context, filterData, chartsData);
@ -449,136 +649,186 @@ class _ChartScreen1State extends State<ChartScreen1> {
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Left arrow button
_buildArrowButton(
onPressed: _activeTabIndex > 0 ? _scrollLeft : null,
icon: Icons.arrow_back_ios_new,
),
// Tabs with horizontal scroll
Expanded(
child: SingleChildScrollView(
controller: _scrollController,
scrollDirection: Axis.horizontal,
child: Row(
children:
List.generate(_tabsData.length, (index) {
return _buildTab(
_tabsData[index],
isActive: index == _activeTabIndex,
);
}),
),
),
),
// Right arrow button
_buildArrowButton(
onPressed: _activeTabIndex < _tabsData.length - 1
? _scrollRight
: null,
icon: Icons.arrow_forward_ios,
),
],
),
// Expanded(
// child: Center(
// child: Text(
// 'Selected Tab: ${_tabsData.isNotEmpty ? _tabsData[_activeTabIndex] : 'None'}',
// style: const TextStyle(fontSize: 18),
// ),
// ),
// ),
// nonChartData Cards
GridView.builder(
itemCount: cardData.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, // 2 cards per row
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 190.5 /
200, // Adjusted to maintain width and fixed height
),
itemBuilder: (context, index) {
final item = cardData[index];
print('item item item $item');
final chart_type = item['chart_type'];
final chart_heading = item['chart_heading'];
final data = apiService.processNonChartData(item);
print('processNonChartData');
Padding(
padding: const EdgeInsets.all(3.34),
child: GridView.builder(
itemCount: cardData.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: cardData.length == 2
? 2
: cardData.length == 3
? 3
: cardData.length == 4
? 2
: 3, // Default to 3 if more than 4 items // 2 cards per row
crossAxisSpacing: 2,
mainAxisSpacing: 5,
childAspectRatio:
calculateAspectRatio(cardData.length)),
itemBuilder: (context, index) {
final item = cardData[index];
print('item item item $item');
final chart_type = item['chart_type'];
final chart_heading = item['chart_heading'];
final data = apiService.processNonChartData(item);
print('processNonChartData');
if (chart_type == 'total') {
return Card(
margin: const EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.public,
color: Color(0xFF90B0D5), size: 30),
const SizedBox(height: 3),
Text(
'${chart_heading ?? 'NA'}',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
color: Colors.black87,
),
),
Text(
'(${data['lastYear'] ?? 'NA'})',
style: const TextStyle(
fontSize: 11, color: Colors.grey),
),
Text(
apiService
.formatAmount(data['lastYearValue']),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Color(0xFF90B0D5),
),
),
SizedBox(
height: 5, // Height of the divider
child: Divider(
color: Colors.grey,
thickness: 1, // Divider line thickness
),
),
Text(
apiService.formatAmount(
data['secondLastYearValue']),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFFD83731),
),
),
Text(
'(${data['secondLastYear'] ?? 'NA'})',
style: const TextStyle(
fontSize: 11, color: Colors.grey),
),
],
if (chart_type == 'total') {
return Card(
margin: const EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
);
} else if (chart_type == 'average') {
return Card(
margin: const EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.analytics,
color: Color(0xFF90B0D5), size: 30),
const SizedBox(height: 5),
Text(
'${chart_heading ?? 'NA'}',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
color: Colors.black87,
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.public,
color: Color(0xFF90B0D5), size: 30),
const SizedBox(height: 3),
Text(
'${chart_heading ?? 'NA'}',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
color: Colors.black87,
),
),
),
Text(
'(${data['firstYear'] ?? 'NA'} - ${data['lastYear'] ?? 'NA'})',
style: const TextStyle(
fontSize: 11, color: Colors.grey),
),
Text(
'${data['roundedAverage'] ?? 'NA'}',
style: const TextStyle(
fontSize: 26,
fontWeight: FontWeight.w900,
color: Color(0xFF11AF22),
Text(
'(${data['lastYear'] ?? 'NA'})',
style: const TextStyle(
fontSize: 11, color: Colors.grey),
),
),
],
Text(
apiService.formatAmount(
data['lastYearValue']),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w900,
color: Color(0xFF90B0D5),
),
),
SizedBox(
height: 2, // Height of the divider
child: Divider(
color: Colors.grey,
thickness:
1, // Divider line thickness
),
),
Text(
apiService.formatAmount(
data['secondLastYearValue']),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFFD83731),
),
),
Text(
'(${data['secondLastYear'] ?? 'NA'})',
style: const TextStyle(
fontSize: 11, color: Colors.grey),
),
],
),
),
),
);
} else {
return const SizedBox
.shrink(); // Ignore unknown KPIs
}
},
);
} else if (chart_type == 'average') {
return Card(
margin: const EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.analytics,
color: Color(0xFF90B0D5), size: 30),
const SizedBox(height: 5),
Text(
'${chart_heading ?? 'NA'}',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
color: Colors.black87,
),
),
Text(
'(${data['firstYear'] ?? 'NA'} - ${data['lastYear'] ?? 'NA'})',
style: const TextStyle(
fontSize: 11, color: Colors.grey),
),
Text(
'${data['roundedAverage'] ?? 'NA'}',
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.w900,
color: Color(0xFF90B0D5),
),
),
],
),
),
);
} else {
return const SizedBox
.shrink(); // Ignore unknown KPIs
}
},
),
),
// chartsData Cards
ListView.builder(
@ -612,4 +862,58 @@ class _ChartScreen1State extends State<ChartScreen1> {
),
);
}
Widget _buildArrowButton(
{required VoidCallback? onPressed, required IconData icon}) {
final color =
Color(int.parse(widget.bgColor.replaceFirst('0x', ''), radix: 16));
return Container(
margin: EdgeInsets.symmetric(horizontal: 5.0),
width: 35.0, // Set the width of the circle
height: 35.0,
decoration: BoxDecoration(
color: onPressed == null ? Colors.grey[400] : Colors.white,
shape: BoxShape.circle,
// boxShadow: [
// BoxShadow(
// color: Colors.black26,
// blurRadius: 4.0,
// offset: Offset(2, 2),
// ),
// ],
),
child: IconButton(
onPressed: onPressed,
icon: Icon(icon, color: onPressed == null ? Colors.grey : color),
iconSize: 15.0,
),
);
}
Widget _buildTab(Map<String, String> tab, {bool isActive = false}) {
return GestureDetector(
onTap: () {
setState(() {
_activeTabIndex = _tabsData.indexOf(tab);
});
_scrollToIndex(_activeTabIndex);
onTabSelected(tab['id']!);
},
child: Container(
margin: EdgeInsets.symmetric(horizontal: 8.0),
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 16.0),
decoration: BoxDecoration(
color: isActive ? Colors.white : Colors.grey[400],
borderRadius: BorderRadius.circular(20.0),
),
child: Text(
tab['name']!,
style: TextStyle(
color: isActive ? Colors.black : Colors.white,
fontWeight: isActive ? FontWeight.w500 : FontWeight.w400,
),
),
),
);
}
}

View File

@ -294,46 +294,64 @@ class ChartWidget extends StatelessWidget {
aspectRatio: 1.5,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceBetween,
alignment: BarChartAlignment.start,
barTouchData: BarTouchData(
touchTooltipData: BarTouchTooltipData(
// tooltipBgColor: Colors.black.withOpacity(0.8),
fitInsideHorizontally: true,
fitInsideVertically: false,
tooltipPadding: const EdgeInsets.all(8),
tooltipMargin: 16,
getTooltipItem:
(groupData, groupIndex, rodData, rodIndex) {
// print('groupData $groupData');
// print('groupIndex $groupIndex');
// print('rodData $rodData');
// print('rodIndex $rodIndex');
// Assume groupedData is passed as a parameter
// List<String> timePeriods =
// groupedData.values.first.keys.toList();
// String timePeriod = timePeriods[groupIndex];
// List<BarChartRodStackItem> rodStackItems =
// rodData.rodStackItems;
//
// String tooltipText = '';
// for (int i = 0; i < rodStackItems.length; i++) {
// double fromY = rodStackItems[i].fromY;
// double toY = rodStackItems[i].toY;
// double value = toY - fromY;
// String groupName = groupedData.keys.elementAt(i);
//
// tooltipText +=
// '$timePeriod - ${value.toStringAsFixed(0)} - $groupName\n';
// }
//
// return BarTooltipItem(
// tooltipText,
// TextStyle(color: Colors.white, fontSize: 12),
// );
// Get the list of group names dynamically
List<String> groupNames = [];
for (var entry in chartData['response']) {
String groupValue = entry['ObsKey'][groupByKey];
if (!groupNames.contains(groupValue)) {
groupNames.add(groupValue);
}
}
// Accessing the stacked rod items and calculating the tooltip text
List<BarChartRodStackItem> rodStackItems =
rodData.rodStackItems;
List<TextSpan> tooltipTextSpans = [];
for (int i = 0; i < rodStackItems.length; i++) {
double fromY = rodStackItems[i].fromY;
double toY = rodStackItems[i].toY;
double value = toY - fromY;
String groupName = groupNames[i];
// Get the color for the current group
Color groupColor = _getColorForGroup(
i); // Replace with your color logic
// Add a TextSpan for the colored circle and the group name with value
tooltipTextSpans.addAll([
TextSpan(
text: '',
style: TextStyle(
color: groupColor,
fontSize: 14), // Circle color
),
TextSpan(
text:
'$groupName - ${value.toStringAsFixed(0)}\n',
style:
TextStyle(color: Colors.white, fontSize: 12),
),
]);
}
return BarTooltipItem(
'',
TextStyle(color: Colors.white, fontSize: 12),
children: tooltipTextSpans,
);
},
),
// touchCallback: (BarTouchResponse touchResponse) {
// // Handle touch events, such as hover
// if (touchResponse.touchInput is PointerDownEvent) {
// // If you want to handle touch down events, you can add your logic here.
// print('Bar touched: ${touchResponse.touchInput}');
// }
// },
handleBuiltInTouches: true, // Enable built-in touch events
),
titlesData: FlTitlesData(
@ -359,7 +377,7 @@ class ChartWidget extends StatelessWidget {
rightTitles:
AxisTitles(sideTitles: SideTitles(showTitles: false)),
),
gridData: FlGridData(show: true),
gridData: FlGridData(show: false),
borderData: FlBorderData(show: false),
barGroups: _generateBarGroups(chartData, groupByKey),
),
@ -389,11 +407,23 @@ class ChartWidget extends StatelessWidget {
),
),
SizedBox(width: 5),
Text(
group,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11),
),
Tooltip(
message: group,
waitDuration: Duration(milliseconds: 500),
showDuration: Duration(seconds: 2),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(4),
),
textStyle: TextStyle(color: Colors.white),
child: Text(
group.length > 10
? '${group.substring(0, 10)}...'
: group,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11),
),
)
],
);
}).toList();

View File

@ -149,7 +149,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
);
print('userDetails: $userDetailsResponse');
setState(() {
_usernameController.text = userDetailsResponse.data['username'] ?? '';
_usernameController.text = userDetailsResponse.data['uname'] ?? '';
_emailController.text = userDetailsResponse.data['email'] ?? '';
role = userDetailsResponse.data['role'] ?? '';
});

View File

@ -227,7 +227,9 @@ class EconomyStatsState extends State<EconomyStatsWidget> {
bool isLoading = true;
@override
void initState() {
super.initState();
fetchData();
}
@ -238,7 +240,35 @@ class EconomyStatsState extends State<EconomyStatsWidget> {
if (response.statusCode == 200) {
setState(() {
data = json.decode(response.body);
print("HomeDAta $data");
// print("HomeDAta $data");
// Sort data after fetching to ensure the correct order
data.forEach((mainTopic) {
if (mainTopic['tile_data'] != null) {
// print('Original tile_data: ${mainTopic['tile_data']}');
mainTopic['tile_data']?.sort((a, b) {
try {
final aOrder = int.tryParse(
a['data_set_list_order']?.toString() ?? '0') ??
0;
final bOrder = int.tryParse(
b['data_set_list_order']?.toString() ?? '0') ??
0;
return aOrder.compareTo(bOrder);
} catch (e) {
// Handle any errors during sorting
print('Error during sorting: $e');
return 0; // In case of an error, don't alter the order
}
});
// Print the sorted tile_data
// print('Sorted tile_data: ${mainTopic['tile_data']}');
}
});
isLoading = false;
});
} else {
@ -256,99 +286,122 @@ class EconomyStatsState extends State<EconomyStatsWidget> {
double myheight = MediaQuery.of(context).size.height;
double mywidth = MediaQuery.of(context).size.width;
return Expanded(
child: Container(
height: myheight,
// color: Colors.cyan,
child: Padding(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
children: data.map((mainTopic) {
String colorPattern = mainTopic['color_pattern'];
Color backgroundColor = Color(int.parse(colorPattern));
Color borderColor =
backgroundColor; // Use the same color for the border
if (isLoading) {
return Center(child: CircularProgressIndicator());
} else if (data.isEmpty) {
return Center(child: Text("No data available"));
}
// final totalTiles = mainTopic['sub_topics']
// .expand((subTopic) => (subTopic['tile_data'] as List<dynamic>? ?? []))
// .length;
return Container(
height: myheight,
// color: Colors.cyan,
child: Padding(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
children: data.map((mainTopic) {
String colorPattern = mainTopic['color_pattern'];
// Color backgroundColor = Color(int.parse(colorPattern));
final totalTiles =
(mainTopic['tile_data'] as List<dynamic>?)?.length ?? 0;
Color backgroundColor;
try {
backgroundColor = Color(int.parse(colorPattern));
} catch (e) {
backgroundColor = Colors.grey; // Fallback color
print('Invalid color format: $colorPattern');
}
// Compute crossAxisCount dynamically
final crossAxisCount =
(totalTiles / 2).ceil(); // Divide by 2 and round up
Color borderColor =
backgroundColor; // Use the same color for the border
return Expanded(
child: Container(
// color: Colors.cyan,
height:
myheight, // Set the background color for the entire Column
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RoundedCornerContainer(
text: mainTopic['main_topic'],
backgroundColor: backgroundColor,
textStyle: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Colors.white,
),
// final totalTiles = mainTopic['sub_topics']
// .expand((subTopic) => (subTopic['tile_data'] as List<dynamic>? ?? []))
// .length;
final totalTiles =
(mainTopic['tile_data'] as List<dynamic>?)?.length ?? 0;
// Compute crossAxisCount dynamically
// final crossAxisCount = (totalTiles / 2).ceil(); // Divide by 2 and round up
// final crossAxisCount = (totalTiles / 2).ceil().clamp(1, 2); // Safeguard
final crossAxisCount =
totalTiles > 0 ? (totalTiles / 2).ceil().clamp(1, 2) : 1;
return Expanded(
child: Container(
// color: Colors.cyan,
height:
myheight, // Set the background color for the entire Column
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RoundedCornerContainer(
text: mainTopic['main_topic'],
backgroundColor: backgroundColor,
textStyle: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Colors.white,
),
SizedBox(
height: myheight / 4.8, // Set dynamic height
child: Container(
// color: Colors.grey[200], // Set a background color for the scrollable container
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 2,
),
SizedBox(
height: myheight / 4.8, // Set dynamic height
child: Container(
// color: Colors.grey[200], // Set a background color for the scrollable container
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 2,
),
child: MasonryGridView.builder(
gridDelegate:
SliverSimpleGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
),
child: MasonryGridView.builder(
gridDelegate:
SliverSimpleGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
),
physics: const NeverScrollableScrollPhysics(),
itemCount: totalTiles,
itemBuilder: (context, index) {
final tileDataList = (mainTopic['tile_data']
as List<dynamic>?) ??
[];
final tileData = Map<String, String>.from(
tileDataList[index]);
physics: const NeverScrollableScrollPhysics(),
itemCount: totalTiles,
itemBuilder: (context, index) {
final tileDataList =
(mainTopic['tile_data'] as List<dynamic>?) ??
[];
return Container(
margin: const EdgeInsets.all(0),
height: myheight /
9.2, // Variable height for tiles
width: mywidth / 3,
padding:
const EdgeInsets.only(bottom: 3, top: 3),
// color: Colors.yellowAccent.shade100, // Tile background color
child: Flexible(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: _buildRows(
[tileData],
borderColor,
mainTopic['color_pattern']),
final tileData = Map<String, String>.from(
tileDataList[index],
);
return Container(
margin: const EdgeInsets.all(0),
height:
myheight / 9.2, // Variable height for tiles
width: mywidth / 3,
padding:
const EdgeInsets.only(bottom: 3, top: 3),
// color: Colors.yellowAccent.shade100, // Tile background color
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: _buildRows(
[tileData],
borderColor,
mainTopic['color_pattern']),
),
),
),
);
},
),
],
),
);
},
),
),
),
],
),
),
],
),
);
}).toList(),
),
),
);
}).toList(),
),
),
);
@ -401,13 +454,11 @@ class EconomyStatsState extends State<EconomyStatsWidget> {
List<Widget> _buildRows(
List<Map<String, dynamic>> tileData, Color borderColor, color_pattern) {
// Sort the tileData list based on 'data_set_list_order'
// tileData.sort((a, b) => a['data_set_list_order'].compareTo(b['data_set_list_order']));
tileData.sort((a, b) =>
(a['data_set_list_order'] ?? 0).compareTo(b['data_set_list_order'] ?? 0));
// tileData.sort((a, b) =>
// (a['data_set_list_order'] ?? 0).compareTo(b['data_set_list_order'] ?? 0),);
List<Widget> rows = [];
print('tileDataLength: $tileData.length');
// print('tileDataLength: $tileData.length');
for (int i = 0; i < tileData.length; i += 2) {
// Adding a row for every two items
@ -421,7 +472,8 @@ List<Widget> _buildRows(
.map((tile) {
return Expanded(
child: InfoCard(
title: tile['data_set_tile_heading']!,
// title: tile['data_set_tile_heading']!,
title: tile['data_set_tile_heading'] ?? 'Unknown Title',
subtitle: tile['value_source']!,
value: tile['value']!,
dataset: tile['data_set']!,
@ -534,9 +586,10 @@ class InfoCard extends StatelessWidget {
child: Text(
title,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black,
fontSize: 11,
fontWeight: FontWeight.w400,
// color: Colors.black,
color: Color(0xFF000000),
),
),
),
@ -554,8 +607,9 @@ class InfoCard extends StatelessWidget {
subtitle,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 8,
color: Colors.grey,
fontSize: 11,
fontWeight: FontWeight.w400,
color: Color(0xFF8E8E8E),
),
),
],
@ -572,8 +626,8 @@ class InfoCard extends StatelessWidget {
Text(
value,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
fontSize: 26,
fontWeight: FontWeight.w900,
color: textcolor ?? Colors.black,
),
),

View File

@ -159,7 +159,7 @@ class _EditProfileState extends State<EditProfile> {
);
print('userDetails: $userDetailsResponse');
setState(() {
_usernameController.text = userDetailsResponse.data['username'] ?? '';
_usernameController.text = userDetailsResponse.data['uname'] ?? '';
_emailController.text = userDetailsResponse.data['email'] ?? '';
_fullNameController.text = userDetailsResponse.data['full_name'] ?? '';
_selectedCountry = userDetailsResponse.data['country_region'] ?? '';
@ -710,12 +710,15 @@ class _EditProfileState extends State<EditProfile> {
SizedBox(height: 10),
Text.rich(
TextSpan(
text: AppLocalizations.of(context)!.agree,
text: AppLocalizations.of(context)!
.agree,
style:
TextStyle(color: Colors.black),
children: [
TextSpan(
text: AppLocalizations.of(context)!.terms_conditions,
text: AppLocalizations.of(
context)!
.terms_conditions,
style: TextStyle(
color: Colors.blue,
decoration:
@ -728,12 +731,16 @@ class _EditProfileState extends State<EditProfile> {
},
),
TextSpan(
text: AppLocalizations.of(context)!.t_and,
text: AppLocalizations.of(
context)!
.t_and,
style: TextStyle(
color: Colors.black),
),
TextSpan(
text: AppLocalizations.of(context)!.privacy_policy,
text: AppLocalizations.of(
context)!
.privacy_policy,
style: TextStyle(
color: Colors.blue,
decoration:
@ -746,7 +753,9 @@ class _EditProfileState extends State<EditProfile> {
},
),
TextSpan(
text: AppLocalizations.of(context)!.conditions,
text: AppLocalizations.of(
context)!
.conditions,
style: TextStyle(
color: Colors.black),
),

View File

@ -467,7 +467,8 @@ class _FeedbackFormState extends State<FeedbackForm>
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
const SizedBox(height: 10),
Text(AppLocalizations.of(context)!.feedback_failed_msg,
style: const TextStyle(fontSize: 16), textAlign: TextAlign.center),
style: const TextStyle(fontSize: 16),
textAlign: TextAlign.center),
const SizedBox(height: 30),
ElevatedButton(
onPressed: () {

View File

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:pocketbase/pocketbase.dart';
@ -34,6 +36,13 @@ class _BaseScaffoldState extends State<BaseScaffold> {
String? userEmail;
String? userAvatar;
String? role;
String? userNames;
String? userEmails;
String? userAvatars;
String? roles;
String? collectionIds;
String? collectionId;
@override
void initState() {
@ -55,39 +64,125 @@ class _BaseScaffoldState extends State<BaseScaffold> {
userId = fetchedUserId;
});
//print('NAVUser ID: $userId');
_fetchUserData();
_initializeUserData();
} else {
print('No userId found');
// Handle the case where userId is not available
}
}
// Future<void> _fetchUserData() async {
// try {
// final adminAuth = await _pb.admins
// .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com');
// final adminToken = adminAuth.token;
// //print('adminToken- ${adminToken}');
// final userDetailsResponse = await _pb.collection('users').getOne(
// userId!,
// headers: {
// 'Authorization': 'Bearer $adminToken',
// },
// );
// print('NAVuserDetails: $userDetailsResponse');
//
// setState(() {
// userName = userDetailsResponse.data['uname'] ?? '';
// userEmail = userDetailsResponse.data['email'] ?? '';
// userAvatar = userDetailsResponse.data['avatar'] ?? '';
// role = userDetailsResponse.data['role'] ?? '';
// String recordId = userId;
// String collectionId =
// userDetailsResponse.data['collectionId'] ?? '_pb_users_auth_';
//
// if (userAvatar!.isNotEmpty && recordId.isNotEmpty) {
// _avatarUrl =
// 'https://pb.venbait.in/api/files/$collectionId/$recordId/$userAvatar';
// } else {
// _avatarUrl = ''; // Reset to default or empty
// }
// });
// } catch (e) {
// print('Error fetching user details: $e');
// }
// }
Future<void> _initializeUserData() async {
print("Laoding 1");
final prefs = await SharedPreferences.getInstance();
// final userDataString = prefs.getString('userData');
if (prefs.containsKey('userData')) {
// print("Loading user data from local storage: $userData");
final String? userDataString = prefs.getString('userData');
if (userDataString != null) {
// Decode the JSON string into a Map
final Map<String, dynamic> userData = jsonDecode(userDataString);
// Access the userName field
setState(() {
userName = userData['userNames'];
userEmail = userData['userEmails'];
userAvatar = userData['userAvatars'];
role = userData['roles'];
String recordId = userId;
String collectionId = userData['collectionIds'];
if (userAvatar!.isNotEmpty && recordId.isNotEmpty) {
_avatarUrl =
'https://pb.venbait.in/api/files/$collectionId/$recordId/$userAvatar';
} else {
_avatarUrl = ''; // Reset to default or empty
}
});
} else {
print("No user data found in local storage.");
}
} else {
// Fetch data from server and save it to local storage
await _fetchUserData();
}
}
Future<void> _fetchUserData() async {
try {
// print("Fetching _fetchUserData");
final adminAuth = await _pb.admins
.authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com');
final adminToken = adminAuth.token;
//print('adminToken- ${adminToken}');
final userDetailsResponse = await _pb.collection('users').getOne(
userId!,
headers: {
'Authorization': 'Bearer $adminToken',
},
);
print('NAVuserDetails: $userDetailsResponse');
// print('User details fetched from server: $userDetailsResponse');
final userData = {
'userNames': userDetailsResponse.data['uname'] ?? '',
'userEmails': userDetailsResponse.data['email'] ?? '',
'userAvatars': userDetailsResponse.data['avatar'] ?? '',
'roles': userDetailsResponse.data['role'] ?? '',
'collectionIds':
userDetailsResponse.data['collectionId'] ?? '_pb_users_auth_',
};
final prefs = await SharedPreferences.getInstance();
await prefs.setString('userData', jsonEncode(userData));
setState(() {
userName = userDetailsResponse.data['uname'] ?? '';
userEmail = userDetailsResponse.data['email'] ?? '';
userAvatar = userDetailsResponse.data['avatar'] ?? '';
role = userDetailsResponse.data['role'] ?? '';
userNames = userData['userNames'];
userEmails = userData['userEmails'];
userAvatars = userData['userAvatars'];
roles = userData['roles'];
String recordId = userId;
String collectionId =
userDetailsResponse.data['collectionId'] ?? '_pb_users_auth_';
collectionIds = userData['collectionIds'];
if (userAvatar!.isNotEmpty && recordId.isNotEmpty) {
if (userAvatars!.isNotEmpty && recordId.isNotEmpty) {
_avatarUrl =
'https://pb.venbait.in/api/files/$collectionId/$recordId/$userAvatar';
'https://pb.venbait.in/api/files/$collectionIds/$recordId/$userAvatars';
} else {
_avatarUrl = ''; // Reset to default or empty
}
@ -97,6 +192,12 @@ class _BaseScaffoldState extends State<BaseScaffold> {
}
}
Future<void> logout() async {
final prefs = await SharedPreferences.getInstance();
prefs.clear();
context.go('/');
}
@override
Widget build(BuildContext context) {
String currentRoute = GoRouterState.of(context).matchedLocation;
@ -227,7 +328,7 @@ class _BaseScaffoldState extends State<BaseScaffold> {
ListTile(
leading: Icon(Icons.logout),
title: const Text('Logout'),
onTap: () => context.go('/'),
onTap: () => logout(),
),
],
),