tinted static method

String tinted(
  1. Color color, {
  2. bool dark = false,
})

Creates a simple single-color tinted map style based on color. If dark is true, uses darker contrasts for better readability at night.

Implementation

static String tinted(Color color, {bool dark = false}) {
  final hex = _toHexColor(color);
  final textHex = _toHexColor(_adjustLightness(color, dark ? 0.85 : 0.2));
  final strokeHex = _toHexColor(_adjustLightness(color, dark ? -0.6 : -0.3));

  final List<Map<String, dynamic>> style = [
    {
      'elementType': 'geometry',
      'stylers': [
        {'color': hex},
      ],
    },
    {
      'elementType': 'labels.text.fill',
      'stylers': [
        {'color': textHex},
      ],
    },
    {
      'elementType': 'labels.text.stroke',
      'stylers': [
        {'color': strokeHex},
      ],
    },
    {
      'featureType': 'poi',
      'elementType': 'geometry',
      'stylers': [
        {'color': hex},
      ],
    },
    {
      'featureType': 'road',
      'elementType': 'geometry',
      'stylers': [
        {'color': _toHexColor(_adjustLightness(color, dark ? 0.15 : 0.4))},
      ],
    },
    {
      'featureType': 'water',
      'elementType': 'geometry',
      'stylers': [
        {'color': _toHexColor(_adjustLightness(color, dark ? -0.2 : -0.4))},
      ],
    },
  ];
  return _jsonEncode(style);
}