configureBackground method

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

Implementation

Future<bool> configureBackground({
  String? logoPath,
  String? backgroundColorHex,
  String? gradientStartHex,
  String? gradientEndHex,
}) async {
  final params = <String, dynamic>{};
  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 {
    await channel.invokeMethod("configureBackground", params);
    return true;
  } catch (_) {
    return false;
  }
}