dartterm/lib/main.dart

59 lines
1.3 KiB
Dart
Raw Normal View History

2023-09-06 23:38:53 +00:00
import 'package:dartterm/colors.dart';
2023-09-06 03:11:15 +00:00
import 'package:dartterm/terminal.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() {
2023-09-06 19:15:45 +00:00
runApp(const App());
2023-09-06 03:11:15 +00:00
}
2023-09-06 19:15:45 +00:00
class App extends StatelessWidget {
const App({super.key});
2023-09-06 03:11:15 +00:00
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'DARTTERM',
theme: ThemeData(
2023-09-06 23:38:53 +00:00
useMaterial3: true, scaffoldBackgroundColor: Palette.defaultBg),
2023-09-06 03:11:15 +00:00
builder: (BuildContext context, Widget? child) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: child!);
},
2023-09-06 19:15:45 +00:00
home: const Viewer(),
2023-09-06 03:11:15 +00:00
);
}
}
2023-09-06 19:15:45 +00:00
class Viewer extends StatefulWidget {
const Viewer({super.key});
2023-09-06 03:11:15 +00:00
@override
2023-09-06 19:15:45 +00:00
State<Viewer> createState() => _ViewerState();
2023-09-06 03:11:15 +00:00
}
2023-09-06 19:15:45 +00:00
class _ViewerState extends State<Viewer> {
2023-09-06 03:11:15 +00:00
Ticker? ticker;
@override
void initState() {
super.initState();
ticker = Ticker(tick);
ticker!.start();
}
@override
Widget build(BuildContext context) {
2023-09-06 23:38:53 +00:00
return Scaffold(
body: Center(
child: AspectRatio(
aspectRatio: width / height, child: terminal.toWidget(context)),
));
2023-09-06 03:11:15 +00:00
}
void tick(Duration elapsed) {
setState(() {/* state changed, force a redraw */});
}
}