svg: truncate large files in source viewer
This commit is contained in:
parent
a87db49c99
commit
a88d434777
1 changed files with 14 additions and 14 deletions
|
@ -20,6 +20,8 @@ class SourceViewerPage extends StatefulWidget {
|
|||
class _SourceViewerPageState extends State<SourceViewerPage> {
|
||||
late Future<String> _loader;
|
||||
|
||||
static const maxCodeSize = 2 << 16; // 128kB
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
@ -39,24 +41,22 @@ class _SourceViewerPageState extends State<SourceViewerPage> {
|
|||
if (snapshot.hasError) return Text(snapshot.error.toString());
|
||||
if (!snapshot.hasData) return const SizedBox.shrink();
|
||||
|
||||
final source = snapshot.data!;
|
||||
final highlightView = AvesHighlightView(
|
||||
final data = snapshot.data!;
|
||||
final source = data.length < maxCodeSize ? data : '${data.substring(0, maxCodeSize)}\n\n*** TRUNCATED ***';
|
||||
|
||||
return Container(
|
||||
constraints: const BoxConstraints.expand(),
|
||||
child: Scrollbar(
|
||||
child: SingleChildScrollView(
|
||||
child: AvesHighlightView(
|
||||
input: source,
|
||||
language: 'xml',
|
||||
theme: darculaTheme,
|
||||
padding: const EdgeInsets.all(8),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontSize: 10,
|
||||
),
|
||||
tabSize: 4,
|
||||
);
|
||||
return Container(
|
||||
constraints: const BoxConstraints.expand(),
|
||||
child: Scrollbar(
|
||||
child: SingleChildScrollView(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: highlightView,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue