> For the complete documentation index, see [llms.txt](https://infinitys-organization-4.gitbook.io/flutter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitys-organization-4.gitbook.io/flutter/flutter-lessons/osnovy-dart/01.-peremennye-chast-2.md).

# 01. Переменные часть 2

**Видео урок**&#x20;

| `+` | `int`, `double`, `String` | <p><code>int: 5 + 3 = 8</code><br><code>double: 2.5 + 1.5 = 4.0</code><br><code>String: "Hi" + "!" = "Hi!"</code></p> |
| --- | ------------------------- | --------------------------------------------------------------------------------------------------------------------- |

| `-` | `int`, `double` | <p><code>5 - 2 = 3</code><br><code>4.5 - 1.5 = 3.0</code></p> |
| --- | --------------- | ------------------------------------------------------------- |

| `*` | `int`, `double`, `String`\* | <p><code>3 \* 2 = 6</code><br><code>2.5 \* 2 = 5.0</code><br><code>"ha" \* 3 = "hahaha"</code></p> |
| --- | --------------------------- | -------------------------------------------------------------------------------------------------- |

| `/` | `int`, `double` | <p><code>5 / 2 = 2.5</code><br><code>4 / 2 = 2.0</code></p> |
| --- | --------------- | ----------------------------------------------------------- |

| `~/` | `int`, `double` | <p><code>5 \~/ 2 = 2</code><br><code>5.0 \~/ 2 = 2</code></p> |
| ---- | --------------- | ------------------------------------------------------------- |

| `%` | `int`, `double` | <p><code>5 % 2 = 1</code><br><code>5.5 % 2 = 1.5</code></p> |
| --- | --------------- | ----------------------------------------------------------- |

| `++` | `int`, `double` | `int a = 5; a++; // a = 6` |
| ---- | --------------- | -------------------------- |

| `--` | `int`, `double` | `double d = 3.0; d--; // d = 2.0` |
| ---- | --------------- | --------------------------------- |

| `+=` | `int`, `double`, `String` | <p><code>int a = 2; a += 3; // 5</code><br><code>String s = "Hi"; s += "!"; // "Hi!"</code></p> |
| ---- | ------------------------- | ----------------------------------------------------------------------------------------------- |

| `-=` | `int`, `double` | `int a = 5; a -= 2; // 3` |
| ---- | --------------- | ------------------------- |

| `*=` | `int`, `double` | `int a = 3; a *= 2; // 6` |
| ---- | --------------- | ------------------------- |

| `/=` | `int`, `double` | `double d = 4.0; d /= 2; // 2.0` |
| ---- | --------------- | -------------------------------- |

| `~/=` | `int`, `double` | `int a = 5; a ~/= 2; // 2` |
| ----- | --------------- | -------------------------- |

| `%=` | `int`, `double` | `int a = 5; a %= 2; // 1` |
| ---- | --------------- | ------------------------- |

{% embed url="<https://youtu.be/Gt9Mqjm46Ew>" %}

**Исходный код**

{% code lineNumbers="true" %}

```dart
// Some code
import 'package:flutter/material.dart';

class Lesson02 extends StatefulWidget {
  const Lesson02({super.key});

  @override
  State<Lesson02> createState() => _Lesson02State();
}

class _Lesson02State extends State<Lesson02> {
  String title = '';
  int number = 0;
  double counter = 0;
  bool isAdult = true;

  var textVar = const Text('Hello');
  var name = 'Baias';
  var age = 45;

  dynamic textDynamic = const Text('Hello');
  dynamic nameDynamic = 'Baias';
  dynamic ageDynamic = 45;

  Widget text = const Text('Hello');
  Icon icon = const Icon(Icons.add);

  bool isLike = false;
  bool isChangeContainer = false;

  // TODO : =, -, +, *, /, !
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: title.isEmpty ? const Center(child: Text('No data'),): Column(
          children: [
            Text(
              '${title.length}',
              style: const TextStyle(fontSize: 30),
            ),
            Text(
              '${title.isEmpty}',
              style: const TextStyle(fontSize: 30),
            ),
            Text(
              '${title.isNotEmpty}',
              style: const TextStyle(fontSize: 30),
            ),
            Text(
              '${title.runtimeType}',
              style: const TextStyle(fontSize: 30),
            ),
            Text(
              title,
              style: const TextStyle(fontSize: 30),
            ),
            Row(
              children: [
                ElevatedButton(
                    onPressed: () {
                      setState(() {
                        title = title.toUpperCase();
                      });
                    },
                    child: const Text('Upper case')),
                ElevatedButton(
                    onPressed: () {
                      setState(() {
                        title = title.toLowerCase();
                      });
                    },
                    child: const Text('Lower case')),
              ],
            ),
            const SizedBox(
              height: 20,
            ),
            Text(
              '$number',
              style: const TextStyle(fontSize: 30),
            ),
            Row(
              children: [
                ElevatedButton(
                    onPressed: () {
                      setState(() {
                        number = number.toString().length;
                      });
                    },
                    child: const Text('+')),
                ElevatedButton(
                    onPressed: () {
                      setState(() {
                        number--;
                      });
                    },
                    child: const Text('-')),
              ],
            ),
            Text(
              '${textVar.runtimeType}',
              style: const TextStyle(fontSize: 30),
            ),
            const SizedBox(
              height: 30,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                Text(title),
                Text('$name, $age'),
                Text('$nameDynamic')
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                ElevatedButton(
                    onPressed: () {
                      setState(() {
                        title = 'Hello';
                      });
                    },
                    child: const Text('title')),
                ElevatedButton(
                    onPressed: () {
                      setState(() {
                        name = 'Bakjshdkj';
                        age = 67;
                      });
                    },
                    child: const Text('name')),
                ElevatedButton(
                    onPressed: () {
                      setState(() {
                        nameDynamic = true;
                      });
                    },
                    child: const Text('Dynamic'))
              ],
            ),
            const SizedBox(
              height: 30,
            ),
            IconButton(
              onPressed: () {
                setState(() {
                  isLike = !isLike;
                });
              },
              icon: isLike
                  ? const Icon(
                      Icons.favorite,
                      color: Colors.red,
                    )
                  : const Icon(Icons.favorite_border),
            ),

            Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                Container(
                  height: isChangeContainer ? 100 : 150,
                  width: isChangeContainer ? 100 : 150,
                  color: isChangeContainer ? Colors.red : Colors.blue,
                ),
                TextButton(onPressed: (){
                  setState(() {
                    isChangeContainer = !isChangeContainer;
                  });
                }, child: const Text('change container'))
              ],
            )
          ],
        ),
      ),
    );
  }
}

```

{% endcode %}
