Do Widgets tutorial #1

Merged
kornerr merged 15 commits from tutorial into master 2026-06-04 17:59:51 +02:00
3 changed files with 57 additions and 13 deletions
Showing only changes of commit 2bcea6ab15 - Show all commits

1
abc/lib/tutFun.dart Symbolic link
View File

@@ -0,0 +1 @@
../../src/tutFun.dart

View File

@@ -1,22 +1,48 @@
import 'package:flutter/material.dart';
import 'game.dart';
import 'tutFun.dart';
void main() {
runApp(const MainApp());
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text('Wow, nice, Hello World!'),
),
),
);
}
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
//child: Text('Wow, nice, Hello World!'),
child: Tile("A", HitType.hit),
),
),
);
}
}
class Tile extends StatelessWidget {
const Tile(this.letter, this.hitType, {super.key});
final String letter;
final HitType hitType;
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Text(
letter.toUpperCase(),
style: Theme.of(context).textTheme.titleLarge,
),
),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade300),
color: tutTileColor(hitType),
),
height: 60,
width: 60,
);
}
}

17
src/tutFun.dart Normal file
View File

@@ -0,0 +1,17 @@
library;
import 'package:flutter/material.dart';
import 'game.dart';
Color tutTileColor(HitType t) {
if (t == HitType.hit) {
return Colors.green;
}
if (t == HitType.partial) {
return Colors.yellow;
}
if (t == HitType.miss) {
return Colors.grey;
}
return Colors.white;
}