configureBackground method

Future configureBackground({
  1. String? logoPath,
  2. String? backgroundColorHex,
  3. String? gradientStartHex,
  4. String? gradientEndHex,
})

Implementation

Future<dynamic> configureBackground({
  String? logoPath,
  String? backgroundColorHex,
  String? gradientStartHex,
  String? gradientEndHex,
}) async {
  Map<String, dynamic> params = {};
  if (logoPath != null) params['logoPath'] = logoPath;
  if (backgroundColorHex != null) params['backgroundColor'] = backgroundColorHex;
  if (gradientStartHex != null) params['gradientStart'] = gradientStartHex;
  if (gradientEndHex != null) params['gradientEnd'] = gradientEndHex;

  if (params.isEmpty) {
    throw Exception("At least one parameter is required");
  }

  if (gradientStartHex != null && gradientEndHex == null) {
    throw Exception("gradientEnd is required when gradientStart is informed");
  }

  if (gradientEndHex != null && gradientStartHex == null) {
    throw Exception("gradientStart is required when gradientEnd is informed");
  }

  try {
    channel.invokeMethod(
      "configureBackground",
      params,
    );

    return true;
  } catch (_) {
    return null;
  }
}