getColorPresentation method

Future<Map<String, dynamic>> getColorPresentation(
  1. String filePath, {
  2. required double red,
  3. required double blue,
  4. required double green,
  5. required double alpha,
  6. required Map<String, dynamic> range,
})

Implementation

Future<Map<String, dynamic>> getColorPresentation(
  String filePath, {
  required double red,
  required double blue,
  required double green,
  required double alpha,
  required Map<String, dynamic> range,
}) async {
  if (!capabilities.documentColor) return {'result': []};

  /// Requests color presentation(s) for a color at a given range.
  ///
  /// Sends a `textDocument/colorPresentation` request to the language server
  /// for the document at [filePath]. The [red], [green], [blue], and [alpha]
  /// values should be in the 0.0..1.0 range. [range] is a LSP range map
  /// (with `start`/`end` positions) that identifies where the color appears
  /// in the document. Returns the raw server response as a map; callers
  /// should inspect `response['result']` according to the server's
  /// specification for color presentations.
  final response = await _sendRequest(
    method: "textDocument/colorPresentation",
    params: {
      'textDocument': {'uri': Uri.file(filePath).toString()},
      'color': {'red': red, 'blue': blue, 'green': green, 'alpha': alpha},
      'range': range,
    },
  );
  return response;
}