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

fix: check for nil value when handle_log is called #436

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lua/flutter-tools/dev_tools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ local devtools_profiler_url = nil

local activate_cmd = { "pub", "global", "activate", "devtools" }

-- Android when flutter run starts a new devtools process
-- OLD: Flutter DevTools, a Flutter debugger and profiler,
-- on sdk gphone x86 arm is available at:
-- http://127.0.0.1:9102?uri=http%3A%2F%2F127.0.0.1%3A46051%2FNvCev-HjyX4%3D%2F
-- NEW: The Flutter DevTools debugger and profiler on sdk gphone x86 arm is available at:
-- http://127.0.0.1:9100?uri=http%3A%2F%2F127.0.0.1%3A35479%2FgQ0BNyM2xB8%3D%2F
---Android when flutter run starts a new devtools process
---OLD: Flutter DevTools, a Flutter debugger and profiler,
---on sdk gphone x86 arm is available at:
---http://127.0.0.1:9102?uri=http%3A%2F%2F127.0.0.1%3A46051%2FNvCev-HjyX4%3D%2F
---NEW: The Flutter DevTools debugger and profiler on sdk gphone x86 arm is available at:
--- http://127.0.0.1:9100?uri=http%3A%2F%2F127.0.0.1%3A35479%2FgQ0BNyM2xB8%3D%2F
---@param data string
---@return unknown
local function try_get_tools_flutter(data) return data:match("(https?://127%.0%.0%.1:%d+%?uri=.+)$") end

--- Debug service listening on ws://127.0.0.1:44293/heXbxLM_lhM=/ws
Expand Down Expand Up @@ -75,7 +77,10 @@ function M.open_dev_tools()
end
end

---@param data string?
function M.handle_log(data)
if not data then return end

if devtools_profiler_url or (profiler_url and devtools_url) then return end

devtools_profiler_url = try_get_tools_flutter(data)
Expand Down Expand Up @@ -233,6 +238,7 @@ function M.on_flutter_shutdown()
end

function M.set_devtools_url(url) devtools_url = url end

function M.set_profiler_url(url) profiler_url = url end

return M
Loading