2024-11-01 22:38:39 +04:00

116 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'My first app with flutter'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
int _time = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
void _startTime() {
setState(() {
_time = 0;
});
for (int i = 0; i < 20001; i++) {
Future.delayed(Duration(milliseconds: i), () {
if (_time == 20000) {
_showFullScreenImage();
} else {
setState(() {
_time = i;
});
}
});
}
}
void _showFullScreenImage() {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
insetPadding: EdgeInsets.zero,
child: GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: SizedBox.expand(
child: Image.asset('assets/pict.png', fit: BoxFit.cover),
),
),
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const SizedBox(height: 20),
const Text(
'Timer value:',
),
Text(
'$_time',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
const SizedBox(width: 10),
FloatingActionButton(
onPressed: _startTime,
tooltip: 'Start Timer',
child: const Icon(Icons.timer),
),
],
),
);
}
}