getEditCellStyle method
Get the effective edit style for a cell (font, padding).
Resolves per-cell overrides with grid default fallback.
Returns null if the grid is not created or the query fails.
Implementation
Future<EditCellStyle?> getEditCellStyle(int row, int col) async {
if (!isCreated) return null;
try {
final resp = await getCellsRange(
row,
col,
row,
col,
includeStyle: true,
);
final config = await _getConfig();
final cellFont =
(resp.cells.isNotEmpty) ? resp.cells.first.style.font : null;
final gridFont = config.style.font;
return EditCellStyle(
fontFamily: (cellFont != null &&
cellFont.hasFamily() &&
cellFont.family.isNotEmpty)
? cellFont.family
: (gridFont.hasFamily() ? gridFont.family : null),
fontSize: (cellFont != null && cellFont.hasSize() && cellFont.size > 0)
? cellFont.size.toDouble()
: (gridFont.hasSize() && gridFont.size > 0
? gridFont.size.toDouble()
: null),
bold: (cellFont != null && cellFont.hasBold())
? cellFont.bold
: (gridFont.hasBold() && gridFont.bold),
italic: (cellFont != null && cellFont.hasItalic())
? cellFont.italic
: (gridFont.hasItalic() && gridFont.italic),
padLeft: (resp.cells.isNotEmpty && resp.cells.first.style.hasPadding())
? resp.cells.first.style.padding.left.toDouble()
: (config.style.hasCellPadding()
? config.style.cellPadding.left.toDouble()
: 0),
padTop: (resp.cells.isNotEmpty && resp.cells.first.style.hasPadding())
? resp.cells.first.style.padding.top.toDouble()
: (config.style.hasCellPadding()
? config.style.cellPadding.top.toDouble()
: 0),
padRight: (resp.cells.isNotEmpty && resp.cells.first.style.hasPadding())
? resp.cells.first.style.padding.right.toDouble()
: (config.style.hasCellPadding()
? config.style.cellPadding.right.toDouble()
: 0),
padBottom:
(resp.cells.isNotEmpty && resp.cells.first.style.hasPadding())
? resp.cells.first.style.padding.bottom.toDouble()
: (config.style.hasCellPadding()
? config.style.cellPadding.bottom.toDouble()
: 0),
);
} catch (_) {}
return null;
}