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'."**]
For the first one, botomTiles expects an AxisTitle
, so you should wrap your SideTitle
with an AxisTitle
:
bottomTitles: AxisTitles(
sideTitles: SideTitles(
....
),
),
And for the other errors it seems SideTitles doesn't use those parameters anymore:
/// Determines showing or hiding this side titles
final bool showTitles;
/// You can override it to pass your custom widget to show in each axis value
/// We recommend you to use [SideTitleWidget].
final GetTitleWidgetFunction getTitlesWidget;
/// It determines the maximum space that your titles need,
/// (All titles will stretch using this value)
final double reservedSize;
/// Texts are showing with provided [interval]. If you don't provide anything,
/// we try to find a suitable value to set as [interval] under the hood.
final double? interval;
Check the last version of fi_chart and compare with yours