addWidget method

Future<String> addWidget(
  1. SDNWidget widget
)

Implementation

Future<String> addWidget(SDNWidget widget) {
  final user = client.userID;
  final widgetId =
      '${widget.name!.toLowerCase().replaceAll(RegExp(r'\W'), '_')}_${user!}';

  final json = widget.toJson();
  json['creatorUserId'] = user;
  json['id'] = widgetId;
  return client.setRoomStateWithKey(
    id,
    'im.vector.modular.widgets',
    widgetId,
    json,
  );
}