You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中enable-web显示true(Unavailable)的原因及浏览器设备连接方法

Why does enable-web show true but unavailable, and how to connect a browser as a Flutter device?

Let's break down your problem and walk through practical fixes step by step:

Why enable-web shows "true (Unavailable)"

This status tells you Flutter has registered your request to enable web support, but it can't access the necessary dependencies or meet environment requirements to activate it. The cgroup v2 warning you're seeing is a critical hint—older Flutter versions had limited compatibility with cgroup v2, which is the default on many modern Linux distributions.

Step-by-Step Solutions

1. Fix cgroup v2 compatibility issues

The "partial confinement" warning points to cgroup v2 being unsupported. You have two options here:

  • Temporary fix (requires reboot): Switch back to cgroup v1 via GRUB:
    1. Open your GRUB config file with a text editor:
      sudo nano /etc/default/grub
      
    2. Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT, add systemd.unified_cgroup_hierarchy=0 inside the quotes. For example:
      GRUB_CMDLINE_LINUX_DEFAULT="quiet splash systemd.unified_cgroup_hierarchy=0"
      
    3. Save the file and update GRUB:
      sudo update-grub
      
    4. Reboot your system.
  • Permanent fix: Upgrade Flutter to the latest stable release (newer versions have improved cgroup v2 support):
    flutter upgrade
    

2. Verify Chrome is installed and accessible

Flutter uses Chrome as its default web device. Confirm it's set up correctly:

  • Run google-chrome --version in your terminal. If you get an error, install Chrome first.
  • If you prefer Microsoft Edge, enable it explicitly with:
    flutter config --enable-edge-web
    

3. Run flutter doctor to diagnose missing dependencies

This command will flag any gaps in your setup:

flutter doctor -v

Look for the "Web" section—it will tell you if Chrome is missing, if there's an SDK mismatch, or other configuration issues. Fix any errors it reports (like installing missing components).

4. Restart your terminal and IDE

The initial command warned you to restart editors for settings to take effect. Close and reopen your terminal, IDE, or code editor to ensure the updated Flutter config loads properly.

5. Manually connect a browser (if flutter devices still shows none)

If the above steps don't work, force Chrome to listen for debugging connections:

  1. Close all running Chrome windows.
  2. Launch Chrome with the remote debugging flag:
    google-chrome --remote-debugging-port=9222
    
  3. Run flutter devices again—Chrome should now appear as a connected device.

After completing these steps, you should see your browser listed in flutter devices and be able to start developing Flutter web apps normally.

内容的提问来源于stack exchange,提问作者Prakash Ramasamy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 17:12:37