currently I’m facing error in Fl_chart flutter. In part of my code I insert bottomTitles: SideTitles but system shown error ["The argument type ‘SideTitles’ can’t be assigned to the parameter type ‘AxisTitles‘.].
`bottomTitles: SideTitles(
showTitles: true,
rotateAngle:
MediaQuery.of(context).size.width > 400 ? -45 : -90,
reservedSize: MediaQuery.of(context).size.width > 500
? MediaQuery.of(context).size.height * 0.03
: MediaQuery.of(context).size.height * 0.08,
getTitles: (value) {
final hour = value.toInt();
final formattedHour =
(hour % 12 == 0) ? '12' : (hour % 12).toString();
final period = (hour < 12) ? 'AM' : 'PM';
if (formattedHour + period == previousHour) {
return '';
}
// Store the current title to check for duplicates in the next iteration
previousHour = formattedHour + period;
return '$formattedHour $period';
},
),`
Error Detail As Below:
I try change the SideTitles into AxisTitles system pop out another 4 Errors(refer as below), after that I search in chatGPT say that below parameters only able to use in SideTitles & advice me seek advice in library comunity.
Can anyone Help me in this issue? Thank you in advance!
-[**"The named parameter 'rotateAngle' isn't defined.nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'rotateAngle'."**]
-[**"The named parameter 'getTitles' isn't defined.nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'getTitles'."**]
-[**"The named parameter 'showTitles' isn't defined.nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'showTitles'."**]
-[**"The named parameter 'reservedSize' isn't defined.nTry correcting the name to an existing named parameter's name, or defining a named parameter with the name 'reservedSize'."**]
2
Answers
For the first one, botomTiles expects an
AxisTitle
, so you should wrap yourSideTitle
with anAxisTitle
:And for the other errors it seems SideTitles doesn’t use those parameters anymore:
Check the last version of fi_chart and compare with yours
Wrap your SideTitles in an AxisTitles. Try like below code. Also, check the Latest Version for some changes.
}