2 laba
This commit is contained in:
parent
1f69219a50
commit
c44fecc1b7
6
lib/animal.dart
Normal file
6
lib/animal.dart
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class Animal {
|
||||||
|
final String name;
|
||||||
|
final String description;
|
||||||
|
|
||||||
|
Animal({required this.name, required this.description});
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'animal.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@ -10,60 +11,78 @@ class MyApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Зоопарк',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.brown),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'Сафиулова Камилия Наилевна '),
|
home: const HomeScreen(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
const MyHomePage({super.key, required this.title});
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
int _counter = 0;
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
title: const Text('Зоопарк'),
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: ElevatedButton(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
onPressed: () {
|
||||||
children: <Widget>[
|
Navigator.push(
|
||||||
const Text(
|
context,
|
||||||
'You have pushed the button this many times:',
|
MaterialPageRoute(
|
||||||
),
|
builder: (context) => const AnimalListScreen(),
|
||||||
Text(
|
),
|
||||||
'$_counter',
|
);
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
},
|
||||||
),
|
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), // Увеличиваем размер текста
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user