import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:labs/presentation/home_page/bloc/bloc.dart'; import 'package:labs/presentation/home_page/home_page.dart'; import 'package:labs/repo/potter_repo.dart'; import 'University.dart'; import 'domain/models/Student.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'University App', theme: ThemeData( primarySwatch: Colors.blue, scaffoldBackgroundColor: Colors.white, // Устанавливаем белый фон ), home: ScaffoldMessenger( child: UniversityScreen(), ), ); } } class UniversityScreen extends StatefulWidget { @override _UniversityScreenState createState() => _UniversityScreenState(); } class _UniversityScreenState extends State { final University university = University(); final TextEditingController nameController = TextEditingController(); final TextEditingController ageController = TextEditingController(); List selectedCourses = []; void _addStudent() async { await Future.delayed(Duration(seconds: 1)); String name = nameController.text; int age = int.tryParse(ageController.text) ?? 0; if (name.isNotEmpty && age > 0 && selectedCourses.isNotEmpty) { setState(() { // Создаем новый список курсов для каждого студента List studentCourses = List.from(selectedCourses); university.addStudent(Student(name, age, studentCourses)); nameController.clear(); ageController.clear(); selectedCourses.clear(); }); } } @override Widget build(BuildContext context) { return MaterialApp( title: 'Строев Владимир, ПИбд-32', debugShowCheckedModeBanner: false, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.orangeAccent), useMaterial3: true, scaffoldBackgroundColor: Colors.white, // Устанавливаем белый фон ), home: RepositoryProvider( lazy: true, create: (_) => PotterRepo(), child: BlocProvider( lazy: false, create: (context) => HomeBloc(context.read()), child: Scaffold( body: const MyHomePage(), ), ), ), ); } }