dartterm/lib/main.dart

59 lines
1.2 KiB
Dart

import 'package:dartterm/terminal.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
const App({super.key});
@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!);
},
home: const Viewer(),
);
}
}
class Viewer extends StatefulWidget {
const Viewer({super.key});
@override
State<Viewer> createState() => _ViewerState();
}
class _ViewerState extends State<Viewer> {
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 */});
}
}