👨🏫0.6 Условия - if(){} - else if(){} - else{}
== - равно, <,>
import 'package:flutter/material.dart';
class Lesson19 extends StatefulWidget {
const Lesson19({super.key});
@override
State<Lesson19> createState() => _Lesson19State();
}
class _Lesson19State extends State<Lesson19> {
// ==, >, <, >=, <=, is, ||, &&
TextEditingController nameController = TextEditingController();
String title = 'Welocme';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
spacing: 20,
children: [
Text(title, style: TextStyle(fontSize: 40)),
TextFormField(
controller: nameController,
decoration: InputDecoration(border: OutlineInputBorder()),
),
ElevatedButton(
onPressed: () {
setState(() {
if (nameController.text == 'Daniel') {
title = 'Привет Даниэль';
} else if (nameController.text == 'saikal') {
title = 'Hello Saikal';
} else if (nameController.text == 'Eldiar') {
title = 'Истина';
} else{
title = 'не смогли вас найти';
}
});
},
child: Text('Apply'),
),
],
),
),
);
}
}Last updated