👨‍🏫0.2 Переменные и операторы

// Some code


import 'package:flutter/material.dart';

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

  @override
  State<Lesson15> createState() => _Lesson15State();
}

class _Lesson15State extends State<Lesson15> {
  //  = String, int, double, bool,
  //
  // int double  = , +=, -=, *=, /=, %, ~/


  int number = 12;
  double numberOne = 456.0;
  int numberTwo = 1;


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Column(
        children: [
          Text('$number', style: TextStyle(fontSize: 40),),
          ElevatedButton(onPressed: (){
            setState(() {
              number *= 3;
            });

          }, child: Text('Умножить')),


          Text('$numberOne', style: TextStyle(fontSize: 40),),
          ElevatedButton(onPressed: (){
            setState(() {
              numberOne /= 3;
            });

          }, child: Text('Делить')),

          Row(
            children: [
              Text('$numberTwo', style: TextStyle(fontSize: 40),),
              IconButton(onPressed: (){
                setState(() {
                  numberTwo +=1;
                });

              }, icon: Icon(Icons.add_circle))
            ],
          )

        ],
      ),
    );
  }
}

Last updated