addWidget method

Future<String> addWidget(
  1. MatrixWidget widget
)

Implementation

Future<String> addWidget(MatrixWidget 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,
  );
}