Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart library 'dart:ui' is not available on this platform #375

Closed
1 task done
justjew opened this issue Aug 20, 2024 · 2 comments · Fixed by #384 or #382
Closed
1 task done

Dart library 'dart:ui' is not available on this platform #375

justjew opened this issue Aug 20, 2024 · 2 comments · Fixed by #384 or #382

Comments

@justjew
Copy link

justjew commented Aug 20, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When I develop a package and try to run example/lib/main.dart I get the following pack of errors:

Output

../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/app.dart:5:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' as ui;
       ^
../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/app_bar_theme.dart:5:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' show lerpDouble;
       ^
../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/arc.dart:6:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' show lerpDouble;
       ^
../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/badge_theme.dart:5:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' show lerpDouble;
       ^
../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/banner_theme.dart:5:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' show lerpDouble;
       ^
../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/bottom_app_bar_theme.dart:5:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' show lerpDouble;
       ^
../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/bottom_navigation_bar_theme.dart:5:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' show lerpDouble;
       ^
../../../../../.asdf/installs/flutter/3.22.2-stable/packages/flutter/lib/src/material/bottom_sheet_theme.dart:5:8: Error: Dart library 'dart:ui' is not available on this platform.
import 'dart:ui' show lerpDouble;
       ^

Exited (254).

My config

return {
  'akinsho/flutter-tools.nvim',
  lazy = false,
  dependencies = {
    'nvim-lua/plenary.nvim',
    'stevearc/dressing.nvim',
  },
  ft = 'dart',
  config = function()
    require('flutter-tools').setup {
      flutter_path = nil,
      flutter_lookup_cmd = 'asdf where flutter',
      debugger = {
        enabled = true,
        run_via_dap = true,
        exception_breakpoints = {},
        register_configurations = function(_)
          require('dap').configurations.dart = {}
          require('dap.ext.vscode').load_launchjs()
        end,
      },
    }
    require('flutter-tools.lsp').attach()
  end,
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "example",
            "cwd": "/absolute/path/to/package/example",
            "request": "launch",
            "type": "dart",
            "program": "lib/main.dart"
        }
    ]
}

It happens on iOS only.
Android works well.
If run the same launch.json from VSCode it works perfect on both iOS/Android.
Also debugging works good if I cd into example and run it right from there. Or when I run a flutter standart project (not a package)

I DID try to flutter clean, flutter pub cache repair etc. No luck.

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.2.1 23C71 darwin-arm64, locale ru-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.2)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Expected Behavior

I expect it to work

Steps To Reproduce

  1. Create a flutter package and example project inside it
  2. Create launch.json
  3. Run dap.continue() and select example option

Environment

- OS: MacOS 14.2.1
- Flutter version: 3.22.2
- Is flutter in $PATH: Using asdf
- neovim version: v0.10.1

Anything else?

No response

@sidlatau
Copy link
Collaborator

I believe the issue here is that the plugin checks the root pubspec.yaml file, does not find any mention of Flutter, and assumes it is a Dart project. Additionally, the plugin does not seamlessly support the example directory. There is already an issue for this: #329.
The reason why it works in VSCode is because its configuration includes instructions to navigate to the example directory:

"name": "example",
"cwd": "/absolute/path/to/package/example",

For now, the simplest workaround is to manually navigate to the example directory using the cd command, as you suggested. However, the plugin could be enhanced by improving its handling of such cases. It would be beneficial to address project configurations similar to the one mentioned here: #329 (comment).

@sidlatau
Copy link
Collaborator

Your running dart-only package example should work if you add .nvim.lua with the content below in your project root directory.

require("flutter-tools").setup_project({
	{
		name = "Run example",
		target = "lib/main.dart",
		cwd = "example",
	},
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants