run static method
Future<void>
run(})
Prompts for a new value, then saves via onSave or nearest controller.
Implementation
static Future<void> run(
BuildContext context, {
required String column,
required Object? currentValue,
required Map<String, Object?> row,
Future<bool> Function(String column, Object? newValue, Map<String, Object?> row)? onSave,
DbLensController? controller,
bool? isSQLite,
String successMessage = 'Cell updated',
String failureMessage = 'Update failed',
}) async {
final sqlite = isSQLite ?? _inferIsSQLite(context, controller);
final theme = DbLensThemeScope.of(context);
Object? newValue;
try {
newValue = await DbLensCellEditor.show(
context,
column,
currentValue,
isSQLite: sqlite,
theme: theme,
);
} on DbLensCellEditCancelled {
return;
}
if (!context.mounted) return;
if (onSave != null) {
final ok = await onSave(column, newValue, row);
if (context.mounted) {
showDbLensSnack(context, ok ? successMessage : failureMessage, isError: !ok);
}
return;
}
final c = controller ?? DbLensControllerScope.maybeOf(context);
if (c == null) return;
final ok = await c.updateCellValue(column: column, newValue: newValue, row: row);
if (context.mounted && ok) {
showDbLensSnack(context, successMessage);
} else if (context.mounted) {
showDbLensSnack(context, failureMessage, isError: true);
}
}