init method

  1. @override
Future<int?> init({
  1. required String name,
  2. required FontWeight weight,
  3. required Color color,
  4. required double size,
})
override

Implementation

@override
Future<int?> init({
  required String name,
  required FontWeight weight,
  required Color color,
  required double size,
}) async {
  final hexColor =
      color.value.toRadixString(16).padLeft(8, '0').toUpperCase();

  try {
    final result = await methodChannel.invokeMethod('init', {
      'name': name,
      'weight': weight.index + 1,
      'color': '#$hexColor',
      'size': size,
    });

    return result[idKey];
  } catch (e) {
    if (kDebugMode) print('SfSymbols init: $e');
    return null;
  }
}