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,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'game.dart'; import 'game.dart';
import 'tutFun.dart';
void main() { void main() {
runApp(const MainApp()); runApp(const MainApp());
@@ -14,9 +14,35 @@ class MainApp extends StatelessWidget {
return const MaterialApp( return const MaterialApp(
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: Text('Wow, nice, Hello World!'), //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;
}