flutterdart-ui

ui.TextLeadingDistribution not found when running Flutter app on chrome or macos


When trying to run my app on chrome or macos after using dart migrate, I get this errors in the console:

Downloading Web SDK...                                           2,674ms
Launching lib/web/main.dev.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...          
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.1/lib/custom_style.dart:38:7: Error: Type 'ui.TextLeadingDistribution' not found.
      ui.TextLeadingDistribution? leadingDistribution,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.1/lib/custom_style.dart:98:7: Error: Type 'ui.TextLeadingDistribution' not found.
      ui.TextLeadingDistribution? leadingDistribution,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.1/lib/custom_style.dart:219:3: Error: Type 'ui.TextLeadingDistribution' not found.
  ui.TextLeadingDistribution? get leadingDistribution =>

It runs fine on the Android / iPhone emulators.
I tried the following but all in vain:

  1. flutter 2.0.6 (stable)
  2. flutter 2.5.3 (stable)
  3. flutter doctor shows nothing wrong
  4. flutter clean, flutter pub cache repair, flutter pub get
  5. Restart VSCode

Solution

  • Actually, the issue was coming from the dependency styled_text.
    I copied only the files that we needed from the repo and that solved the issue.