dartterm/lib/main.dart

59 lines
1.2 KiB
Dart
Raw Normal View History

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(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
useMaterial3: true,
),
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) {
return Center(
child:
AspectRatio(aspectRatio: 16 / 9.0, child: terminal.toWidget(context)),
);
}
void tick(Duration elapsed) {
setState(() {/* state changed, force a redraw */});
}
}