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> {
|
class _SourceViewerPageState extends State<SourceViewerPage> {
|
||||||
late Future<String> _loader;
|
late Future<String> _loader;
|
||||||
|
|
||||||
|
static const maxCodeSize = 2 << 16; // 128kB
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -39,24 +41,22 @@ class _SourceViewerPageState extends State<SourceViewerPage> {
|
||||||
if (snapshot.hasError) return Text(snapshot.error.toString());
|
if (snapshot.hasError) return Text(snapshot.error.toString());
|
||||||
if (!snapshot.hasData) return const SizedBox.shrink();
|
if (!snapshot.hasData) return const SizedBox.shrink();
|
||||||
|
|
||||||
final source = snapshot.data!;
|
final data = snapshot.data!;
|
||||||
final highlightView = AvesHighlightView(
|
final source = data.length < maxCodeSize ? data : '${data.substring(0, maxCodeSize)}\n\n*** TRUNCATED ***';
|
||||||
input: source,
|
|
||||||
language: 'xml',
|
|
||||||
theme: darculaTheme,
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
textStyle: const TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
tabSize: 4,
|
|
||||||
);
|
|
||||||
return Container(
|
return Container(
|
||||||
constraints: const BoxConstraints.expand(),
|
constraints: const BoxConstraints.expand(),
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: SingleChildScrollView(
|
child: AvesHighlightView(
|
||||||
scrollDirection: Axis.horizontal,
|
input: source,
|
||||||
child: highlightView,
|
language: 'xml',
|
||||||
|
theme: darculaTheme,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
textStyle: const TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
tabSize: 4,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue