This commit is contained in:
kamilia 2024-09-23 21:30:34 +04:00
parent 1f69219a50
commit c44fecc1b7
2 changed files with 63 additions and 38 deletions

6
lib/animal.dart Normal file
View File

@ -0,0 +1,6 @@
class Animal {
final String name;
final String description;
Animal({required this.name, required this.description});
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'animal.dart';
void main() {
runApp(const MyApp());
@ -10,60 +11,78 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'Зоопарк',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.brown),
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange),
useMaterial3: true,
),
home: const MyHomePage(title: 'Сафиулова Камилия Наилевна '),
home: const HomeScreen(),
);
}
}
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;
void _incrementCounter() {
setState(() {
_counter++;
});
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
title: const Text('Зоопарк'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const AnimalListScreen(),
),
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 20), // Увеличиваем размер кнопки
textStyle: const TextStyle(fontSize: 22), // Увеличиваем размер текста
),
child: const Text('Показать список животных'),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
class AnimalListScreen extends StatelessWidget {
const AnimalListScreen({super.key});
@override
Widget build(BuildContext context) {
final List<Animal> animals = [
Animal(name: 'Лев', description: 'Король зверей'),
Animal(name: 'Слон', description: 'Крупнейшее наземное животное'),
Animal(name: 'Жираф', description: 'Животное с самой длинной шеей'),
Animal(name: 'Тигр', description: 'Большая кошка с полосатым мехом'),
Animal(name: 'Зебра', description: 'Полосатая лошадь'),
];
return Scaffold(
appBar: AppBar(
title: const Text('Список животных'),
),
body: ListView.builder(
itemCount: animals.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(
animals[index].name,
style: const TextStyle(fontSize: 24), // Увеличиваем размер текста
),
subtitle: Text(
animals[index].description,
style: const TextStyle(fontSize: 20), // Увеличиваем размер текста
),
);
},
),
);
}
}