@@ -106,6 +106,22 @@ local function register_default_configurations(paths, is_flutter_project, projec
106106 end
107107end
108108
109+ local function get_current_value (cmd )
110+ local service_activation_params = vm_service_extensions .get_request_params (cmd )
111+ if
112+ not service_activation_params
113+ or not service_activation_params .params .isolateId
114+ then return end
115+
116+ service_activation_params .params = {
117+ isolateId = service_activation_params .params .isolateId
118+ }
119+ dap .session ():request (" callService" , service_activation_params , function (err , result )
120+ if err then return end
121+ vm_service_extensions .set_service_extensions_state (result .method , result .value )
122+ end )
123+ end
124+
109125local function register_dap_listeners (on_run_data , on_run_exit )
110126 local started = false
111127 local before_start_logs = {}
@@ -133,6 +149,11 @@ local function register_dap_listeners(on_run_data, on_run_exit)
133149 dap .listeners .before [" event_dart.serviceExtensionAdded" ][plugin_identifier ] = function (_ , body )
134150 if body and body .extensionRPC and body .isolateId then
135151 vm_service_extensions .set_isolate_id (body .extensionRPC , body .isolateId )
152+ if body .extensionRPC == " ext.flutter.brightnessOverride" then
153+ get_current_value (" brightness" )
154+ elseif body .extensionRPC == " ext.flutter.platformOverride" then
155+ get_current_value (" change_target_platform" )
156+ end
136157 end
137158 end
138159
@@ -280,7 +301,7 @@ function DebuggerRunner:attach(paths, args, cwd, on_run_data, on_run_exit)
280301 end
281302end
282303
283- function DebuggerRunner :send (cmd , quiet )
304+ function DebuggerRunner :send (cmd , quiet , on_response )
284305 if cmd == " open_dev_tools" then
285306 dev_tools .open_dev_tools ()
286307 return
@@ -292,10 +313,11 @@ function DebuggerRunner:send(cmd, quiet)
292313 end
293314 local service_activation_params = vm_service_extensions .get_request_params (cmd )
294315 if service_activation_params then
295- dap .session ():request (" callService" , service_activation_params , function (err , _ )
316+ dap .session ():request (" callService" , service_activation_params , function (err , response )
296317 if err and not quiet then
297318 ui .notify (" Error calling service " .. cmd .. " : " .. err , ui .ERROR )
298319 end
320+ if response and on_response then on_response (response ) end
299321 end )
300322 return
301323 end
0 commit comments