PIbd-31_MasenkinMS_PMU/lib/main.dart

83 lines
1.8 KiB
Dart
Raw Normal View History

2024-09-13 00:51:36 +04:00
import 'dart:math';
2024-09-10 01:32:13 +04:00
import 'package:flutter/material.dart';
2024-09-13 00:51:36 +04:00
import 'comments_widget.dart';
2024-09-10 01:32:13 +04:00
void main() {
2024-09-13 00:51:36 +04:00
runApp(const MyApp());
2024-09-10 01:32:13 +04:00
}
class MyApp extends StatelessWidget {
2024-09-13 00:51:36 +04:00
const MyApp({super.key});
2024-09-10 01:32:13 +04:00
@override
Widget build(BuildContext context) {
return MaterialApp(
2024-09-13 00:51:36 +04:00
title: 'Comments App',
2024-09-10 02:00:11 +04:00
debugShowCheckedModeBanner: false,
2024-09-10 01:32:13 +04:00
theme: ThemeData(
2024-09-13 00:51:36 +04:00
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const MyHomePage(title: 'Comments App'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Color _color = Colors.transparent;
@override
void initState() {
super.initState();
2024-09-13 01:19:44 +04:00
_color = _generateColor();
2024-09-13 00:51:36 +04:00
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: _color,
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.title,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
)),
Text(
'made by Factorino',
style: TextStyle(
fontSize: 12,
fontStyle: FontStyle.italic,
),
),
],
),
2024-09-10 01:41:34 +04:00
),
2024-09-13 00:51:36 +04:00
body: const CommentsWidget(),
2024-09-10 01:32:13 +04:00
);
}
2024-09-13 01:19:44 +04:00
Color _generateColor() {
final Random random = Random();
final int red = (random.nextInt(106) + 150);
final int green = (random.nextInt(106) + 150);
final int blue = (random.nextInt(106) + 150);
return Color.fromARGB(255, red, green, blue);
}
2024-09-10 01:32:13 +04:00
}