@@ -49,9 +49,10 @@ local function _flutter_sdk_dart_bin(flutter_sdk)
4949end
5050
5151--- Get paths for flutter and dart based on the binary locations
52- --- @return table<string , string>
52+ --- @return table<string , string> ?
5353local function get_default_binaries ()
5454 local flutter_bin = fn .resolve (fn .exepath (" flutter" ))
55+ if # flutter_bin <= 0 then return nil end
5556 return {
5657 flutter_bin = flutter_bin ,
5758 dart_bin = fn .resolve (fn .exepath (" dart" )),
@@ -66,7 +67,7 @@ function M.reset_paths() _paths = nil end
6667
6768--- Execute user's lookup command and pass it to the job callback
6869--- @param lookup_cmd string
69- --- @param callback fun ( p : string , t : table<string , string> ?)
70+ --- @param callback fun ( t ? : table<string , string> ?)
7071--- @return table<string , string> ?
7172local function path_from_lookup_cmd (lookup_cmd , callback )
7273 local paths = {}
@@ -110,7 +111,7 @@ local function _flutter_bin_from_fvm()
110111end
111112
112113--- Fetch the paths to the users binaries.
113- --- @param callback fun ( paths : table<string , string> )
114+ --- @param callback fun ( paths ? : table<string , string> )
114115--- @return nil
115116function M .get (callback )
116117 if _paths then return callback (_paths ) end
@@ -138,14 +139,17 @@ function M.get(callback)
138139
139140 if config .flutter_lookup_cmd then
140141 return path_from_lookup_cmd (config .flutter_lookup_cmd , function (paths )
142+ if not paths then return end
141143 _paths = paths
142144 _paths .dart_sdk = _dart_sdk_root (_paths )
143145 callback (_paths )
144146 end )
145147 end
146148
147- if not _paths then
148- _paths = get_default_binaries ()
149+ local default_paths = get_default_binaries ()
150+
151+ if not _paths and default_paths then
152+ _paths = default_paths
149153 _paths .dart_sdk = _dart_sdk_root (_paths )
150154 if _paths .flutter_sdk then _paths .dart_bin = _flutter_sdk_dart_bin (_paths .flutter_sdk ) end
151155 end
0 commit comments