Flutter Dersleri Bölüm 3 – Hesap Makinesi Yapımı
30 Ekim 2021 / 17:13
Burak
Merhabalar,
Flutter’de textbox kullanımı ve aritmetik işlemlerin kullanımı için olmazsa olmazı olan basit bir hesap makinesi yapımı kodlarıdır.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: "Uygulama Başlığı", home: AnaEkran(), ); } } class AnaEkran extends StatelessWidget { const AnaEkran({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("App Bar Başlığı"), ), body: altislem(), ); } } class altislem extends StatefulWidget { const altislem({Key? key}) : super(key: key); @override _altislemState createState() => _altislemState(); } class _altislemState extends State<altislem> { String isim = 'Test'; int a = 10, b = 5; TextEditingController t1 = TextEditingController(text: "0"); TextEditingController t2 = TextEditingController(text: "0"); void toplama() { setState(() { isim = (num.parse(t1.text) + num.parse(t2.text)).toString(); }); } void cikarma() { setState(() { isim = (num.parse(t1.text) - num.parse(t2.text)).toString(); }); } void carpma() { setState(() { isim = (num.parse(t1.text) * num.parse(t2.text)).toString(); }); } @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.all(20), child: Center( child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ Text(isim), TextField(controller: t1), TextField(controller: t2), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ RaisedButton( onPressed: toplama, child: Text('Topla'), ), RaisedButton( onPressed: cikarma, child: Text('Çıkar'), ), RaisedButton( onPressed: carpma, child: Text('Carp2'), ) ], ) ])), ); } } |
Etiketler: Flutter'de Aritmetik İşlemler, Flutterde matematik işlemleri, Flutterde textbox kullanımı, Flutterde Textbox Okuma
Bu Yazılarıda Okuyabilirsiniz...
Bir cevap yazın