updateWidgetPosition method
Update a widget position in the current layout
Implementation
Future<void> updateWidgetPosition(WidgetPosition position) async {
if (_currentLayoutId == null) {
throw Exception('No current layout selected');
}
final layout = _configCache[_currentLayoutId]!;
// Find the existing position or add a new one
final existingIndex =
layout.positions.indexWhere((p) => p.widgetId == position.widgetId);
if (existingIndex >= 0) {
layout.positions[existingIndex] = position;
} else {
layout.positions.add(position);
}
layout.lastModified = DateTime.now();
await _saveConfig(layout);
}