This commit is contained in:
toly
2023-12-16 12:40:32 +08:00
parent ab2778a22b
commit 01fdf966c5
593 changed files with 8995 additions and 27753 deletions

View File

@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'code/code_widget.dart';
import 'code/highlighter_style.dart';
class CodeView extends StatefulWidget {
final String path;
const CodeView({super.key, required this.path});
@override
State<CodeView> createState() => _CodeViewState();
}
class _CodeViewState extends State<CodeView> {
String? content;
@override
void initState() {
// TODO: implement initState
super.initState();
_loadContent();
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Material(
child: CodeWidget(code:'${content}', style: HighlighterStyle.fromColors(HighlighterStyle.lightColor),),
),
),
);
}
void _loadContent() async{
content = await rootBundle.loadString(widget.path);
setState(() {
});
}
}