htmlSource static method
Shows the raw HTML and lets the user edit it. Returns the edited HTML, or null when cancelled.
Implementation
static Future<String?> htmlSource({required String html, bool editable = true}) {
final TextEditingController controller = TextEditingController(text: _prettyHtml(html));
return UNavigator.dialog<String>(
AlertDialog(
title: Text(U.s.htmlSource),
content: SizedBox(
width: 700,
child: TextField(
controller: controller,
readOnly: !editable,
maxLines: 20,
minLines: 8,
style: const TextStyle(fontFamily: "monospace", fontSize: 12),
decoration: const InputDecoration(border: OutlineInputBorder()),
),
),
actions: <Widget>[
TextButton(onPressed: () => UClipboard.set(controller.text, snackBar: true), child: Text(U.s.copy)),
TextButton(onPressed: UNavigator.back, child: Text(U.s.cancel)),
if (editable) TextButton(onPressed: () => UNavigator.back(controller.text), child: Text(U.s.apply)),
],
),
);
}