From c7ec6c46d131d6f75d03386b7fa3eb28793aa506 Mon Sep 17 00:00:00 2001 From: dominik Date: Wed, 26 Jul 2023 17:22:22 +0000 Subject: [PATCH] Test aktualisiert --- Test | 60 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/Test b/Test index dc36890..12e496a 100644 --- a/Test +++ b/Test @@ -1,34 +1,48 @@ void main() { - print('Hello, World!'); + runApp(MyApp()); } - -int factorial(int n) { - if (n == 0 || n == 1) { - return 1; - } else { - return n * factorial(n - 1); +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: Text('Color Changer'), + ), + body: ColorChanger(), + ), + ); } } -void main() { - int number = 5; - int result = factorial(number); - print('The factorial of $number is $result.'); +class ColorChanger extends StatefulWidget { + @override + _ColorChangerState createState() => _ColorChangerState(); } -int findMax(List numbers) { - int max = numbers[0]; - for (int i = 1; i < numbers.length; i++) { - if (numbers[i] > max) { - max = numbers[i]; - } +class _ColorChangerState extends State { + Color _backgroundColor = Colors.white; + + void changeBackgroundColor() { + setState(() { + _backgroundColor = Color(Random().nextInt(0xFFFFFFFF)); + }); } - return max; -} -void main() { - List numbers = [12, 56, 3, 78, 42, 9]; - int maxNumber = findMax(numbers); - print('The maximum number in the list is $maxNumber.'); + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => changeBackgroundColor(), + child: Container( + color: _backgroundColor, + child: Center( + child: Text( + 'Tap to Change Color', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + ), + ), + ); + } } \ No newline at end of file