The named parameter 'textStyle' isn't defined

Issue

How to fix this error. Someone can help me?
enter image description here

@override
  Widget build(BuildContext context) {    
    return Column(
      children: <Widget>[         
        AspectRatio(
          aspectRatio: 1.70,
          child: Container(     
            height: 250,
            padding: EdgeInsets.all(20),
            child: LineChart(
              mainData(),
            ),
          ),
        ),  
      ],
    );
  }

  LineChartData mainData() {
    return LineChartData(
      gridData: FlGridData(
        show: true,
        drawVerticalLine: true,
        getDrawingHorizontalLine: (value) {
          return FlLine(
            color: Color.fromRGBO(0, 0, 0, 0.3),
            strokeWidth: 1,
          );
        },
        getDrawingVerticalLine: (value) {
          return FlLine(
            color: Color.fromRGBO(0, 0, 0, 0.3),
            strokeWidth: 1,
          );
        },
      ),
      titlesData: FlTitlesData(
        show: true,        
        bottomTitles: SideTitles(
          showTitles: true,          
          reservedSize: 10,      
          rotateAngle: -90,    
          textStyle: const TextStyle(color: Color(0xff68737d), 
 fontWeight: FontWeight.bold, fontSize: 10),
          getTitles: (value) { //ERROR textStyle

Solution

SideTitle’s textStyle property changed to getTextStyles getter (it gives you the axis value, and you must return a TextStyle based on it), It helps you to have a different style for specific text, check it in 0.12.0. Therefore, try:

 getTextStyles: (BuildContext context, double v) {
   return TextStyle(color: Color(0xff68737d), fontWeight: FontWeight.bold, fontSize: 10);
},

Answered By – Muhammad Usama Siddiqui

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.