getMetaThemeColor method

Future<Color?> getMetaThemeColor()

Returns an instance of Color representing the content value of the <meta name="theme-color" content=""> tag of the current WebView, if available, otherwise null.

NOTE: It is implemented using JavaScript.

Implementation

Future<Color?> getMetaThemeColor() async {
  var metaTags = await getMetaTags();
  MetaTag? metaTagThemeColor;

  for (var metaTag in metaTags) {
    if (metaTag.name == "theme-color") {
      metaTagThemeColor = metaTag;
      break;
    }
  }

  if (metaTagThemeColor == null) {
    return null;
  }

  var colorValue = metaTagThemeColor.content;

  return colorValue != null
      ? UtilColor.fromStringRepresentation(colorValue)
      : null;
}