trying to use fl_chart of flutter but when i import it i got this kind of error : Error: 'TextScaler' isn't a type
Asked Answered
M

3

7

Time when trying to import fl_chart.dart it through this error

: Error: 'TextScaler' isn't a type. base_chart_painter.dart:31 final TextScaler textScaler; ^^^^^^^^^^ : Error: The getter 'textScaler' isn't defined for the class 'MediaQueryData'. line_chart_renderer.dart:27

  • 'MediaQueryData' is from 'package:flutter/src/widgets/media_query.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/media_query.dart'). media_query.dart:1 Try correcting the name to the name of an existing getter, or defining a getter or field named 'textScaler'.

how can i solve this error

Mane answered 28/11, 2023 at 9:39 Comment(1)
can you try flutter clean and using latest version of package.Atterbury
A
5

Run flutter upgrade in your terminal to upgrade the Flutter SDK. See the release notes of Flutter here https://docs.flutter.dev/release/release-notes

Appreciative answered 30/11, 2023 at 17:54 Comment(0)
M
4

TextScaler was introduced in Flutter 3.16.0 to replace all textScaleFactor https://docs.flutter.dev/release/breaking-changes/deprecate-textscalefactor

The package author should have updated the package's sdk constraint to flutter: ^3.16.0 to support the new TextScaler.

You could either update your flutter sdk to 3.16.0 up or use an older version of the package which does not introduce the new TextScaler.

Update: check out the github issue here

Macario answered 28/11, 2023 at 15:36 Comment(0)
P
1

Error

 #problem in 0.65.0 not working on flutter 3.13.2 need flutter 3.16    Error: Type 'TextScaler' not found.  TextScaler textScaler,

Fixed by using version 0.60.0

Full example

fl_chart: 0.60.0 
Performative answered 10/12, 2023 at 22:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.