# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infinitys-organization-4.gitbook.io/flutter/flutter-lessons/osnovy-dart/01.-peremennye-chast-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
