@@ -49,9 +49,10 @@ local function _flutter_sdk_dart_bin(flutter_sdk)
49
49
end
50
50
51
51
--- Get paths for flutter and dart based on the binary locations
52
- --- @return table<string , string>
52
+ --- @return table<string , string> ?
53
53
local function get_default_binaries ()
54
54
local flutter_bin = fn .resolve (fn .exepath (" flutter" ))
55
+ if # flutter_bin <= 0 then return nil end
55
56
return {
56
57
flutter_bin = flutter_bin ,
57
58
dart_bin = fn .resolve (fn .exepath (" dart" )),
@@ -66,7 +67,7 @@ function M.reset_paths() _paths = nil end
66
67
67
68
--- Execute user's lookup command and pass it to the job callback
68
69
--- @param lookup_cmd string
69
- --- @param callback fun ( p : string , t : table<string , string> ?)
70
+ --- @param callback fun ( t ? : table<string , string> ?)
70
71
--- @return table<string , string> ?
71
72
local function path_from_lookup_cmd (lookup_cmd , callback )
72
73
local paths = {}
@@ -110,7 +111,7 @@ local function _flutter_bin_from_fvm()
110
111
end
111
112
112
113
--- Fetch the paths to the users binaries.
113
- --- @param callback fun ( paths : table<string , string> )
114
+ --- @param callback fun ( paths ? : table<string , string> )
114
115
--- @return nil
115
116
function M .get (callback )
116
117
if _paths then return callback (_paths ) end
@@ -138,14 +139,17 @@ function M.get(callback)
138
139
139
140
if config .flutter_lookup_cmd then
140
141
return path_from_lookup_cmd (config .flutter_lookup_cmd , function (paths )
142
+ if not paths then return end
141
143
_paths = paths
142
144
_paths .dart_sdk = _dart_sdk_root (_paths )
143
145
callback (_paths )
144
146
end )
145
147
end
146
148
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
149
153
_paths .dart_sdk = _dart_sdk_root (_paths )
150
154
if _paths .flutter_sdk then _paths .dart_bin = _flutter_sdk_dart_bin (_paths .flutter_sdk ) end
151
155
end
0 commit comments