create static method

Future<RenderTheme> create(
  1. DisplayModel displayModel,
  2. String filename, {
  3. Set<String>? excludeIds,
})

Builds and returns a rendertheme by loading a rendertheme file. This is a convienience-function. If desired we can also implement some caching so that we do not need to parse the same file over and over again.

Implementation

static Future<RenderTheme> create(DisplayModel displayModel, String filename, {Set<String>? excludeIds}) async {
  ByteData bytes = await rootBundle.load(filename);
  String content = const Utf8Decoder().convert(bytes.buffer.asUint8List());
  RenderThemeBuilder renderThemeBuilder = RenderThemeBuilder(excludeIds: excludeIds);
  renderThemeBuilder.parseXml(displayModel, content);
  renderThemeBuilder.forHash = "${displayModel.deviceScaleFactor}_${displayModel.fontScaleFactor}_${MapsforgeConstants().tileSize}";
  RenderTheme renderTheme = renderThemeBuilder.build();
  return renderTheme;
}