From d737dbd25273c60e59f78556aa92281a9daadf97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=AF=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=B2?= Date: Mon, 16 Sep 2024 15:27:59 +0400 Subject: [PATCH] lab 1 complete --- lib/main.dart | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 626f59a..bd23f56 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; void main() { @@ -11,11 +13,10 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', - theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange), useMaterial3: true, ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'Яковлев Максим Григорьевич'), ); } } @@ -33,23 +34,24 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { int _counter = 0; + Color _color = Colors.orange; void _incrementCounter() { setState(() { - _counter += 10; + _counter += 10; + _color = Color((Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0); }); } @override Widget build(BuildContext context) { - return Scaffold( + return Scaffold( appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: Text(widget.title), + backgroundColor: _color, + title: Text(widget.title), ), body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, + child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( 'You have pushed the button this many times:', @@ -58,11 +60,17 @@ class _MyHomePageState extends State { '$_counter', style: Theme.of(context).textTheme.headlineMedium, ), + if (_counter > 200) + Text( + 'Stop clicking!', + style: Theme.of(context).textTheme.headlineMedium, + ) ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, + backgroundColor: _color, tooltip: 'Increment', child: const Icon(Icons.add), ), );