Last active
September 6, 2021 19:16
-
-
Save malibayram/f1aeafcfc14ab461c9abf8c813efa2fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
| // for details. All rights reserved. Use of this source code is governed by a | |
| // BSD-style license that can be found in the LICENSE file. | |
| // primitive (değer tipler) variables = değişkenler | |
| // sayılar num, int, double | |
| // metinsel ifadeler string | |
| // evet-hayır ifadeleri bool | |
| // referans tip değişkenler | |
| // koleksiyonlar | |
| // listeler | |
| // map (dictionary) anahtar-değer | |
| // set | |
| // declare => değişken tanımlama | |
| // 1. değişkenin tipi başa yazılır | |
| // 2. değişkene isim verilir. | |
| // 3. atama operatörü kullanılır. | |
| // 4. verilen isme değer (variable) ataması yapılır. | |
| late int z; | |
| int x = 12; | |
| String isim = "Burak"; | |
| double y = 3.2; | |
| bool isikAcikmi = true; | |
| bool onay = false; | |
| // var - dynamic => aynı şey değildir. | |
| String hataninGunu1 = "Pazartesi"; | |
| String hataninGunu2 = "Salı"; | |
| String hataninGunu3 = "Çarşamba"; | |
| List<String> /* generic <VeriTipi> */ haftaninGunleri = ["Pazartesi", "Salı", "Salı"]; | |
| Set tatilGunleri = {"Pazar", "Cumartesi"}; | |
| Map dovizKurlari = {"usd": 8.3, "eur": 10}; | |
| // null pointer exception | |
| // fonksiyonlar | |
| // | |
| // tanımlama => defining | |
| topla(int sayi1, int sayi2) { | |
| print(sayi1 + sayi2); | |
| z = 45; | |
| } | |
| // çağırma => calling | |
| // topla(43, 12); | |
| // buraya yorum yazmış olursun. | |
| /* | |
| bu iki yıldız | |
| arasındaki her | |
| şey yorumdır | |
| */ | |
| // <!-- buraya HTML yorumları --> | |
| // # """ """ | |
| // Variables | |
| // Built-in types | |
| // Functions | |
| // Operators | |
| // Control (if-switch) flow (akış-döngü) (for-while) statements (durumlar) | |
| // eğer (if) oturuyorsa ayağa kalkılır (cevap: true veya false) | |
| bool oturuyormu = true; | |
| bool kapiyaVardim = false; | |
| int kapiyaKadarkiAdimSayisi = 20; | |
| void mutfaktanSuGetir() { | |
| if (oturuyormu) { | |
| // ayagaKalk(); | |
| } | |
| for (int adim = 0; adim < kapiyaKadarkiAdimSayisi; adim++) { | |
| } | |
| kapiyaVardim = true; | |
| while(kapiyaVardim) { | |
| if (kapiyaKadarkiAdimSayisi > 0) { | |
| kapiyaKadarkiAdimSayisi--; | |
| } else { | |
| kapiyaVardim = true; | |
| } | |
| } | |
| } | |
| // void bu fonksiyonun dönüş değerinin tipidir. | |
| // main tanımlanan fonksiyonun ismidir. | |
| // süslü parantezler fonksiyonun yapacağı | |
| // işlemlerin tanımlandığı (anlatıldığı) yerdir | |
| // bu fonksiyon nerede çağrılmış olabilir? | |
| // class => kavram demektir. | |
| class Insan { | |
| bool dusunuyormu = true; | |
| late int dogumYili; | |
| late String isim; | |
| nefesAl() {} | |
| dusun() {} | |
| } | |
| // insandan somut bir örnek => Burak | |
| // her bir somut örneğe de instance (nesne-örnek) diyoruz. | |
| // kavramların özellikleri => property | |
| // kavramların davranışları (eylem-fiil) => method - function | |
| class Madde { | |
| late double ozkutle; | |
| } | |
| class Su extends Madde { | |
| late bool tatliMi; | |
| late bool safMi; | |
| } | |
| class Sinav {} | |
| class Ogrenci extends Insan { | |
| late String okul; | |
| late int sinif; | |
| late double ortalama; | |
| // default => varsayılan constructor | |
| Ogrenci(String gelenIsim, String gelenOkul) { | |
| this.isim = gelenIsim; | |
| this.okul = gelenOkul; | |
| } | |
| // named => isimlendirilmiş constructor | |
| Ogrenci.nakilOlarakOlustur(String gelenIsim, String gelenOkul, double gelenOrtalama) { | |
| this.isim = gelenIsim; | |
| this.okul = gelenOkul; | |
| this.ortalama = gelenOrtalama; | |
| } | |
| Ogrenci.ozelOlarakOlustur() {} | |
| int sinavaGir(Sinav sinav) { | |
| int not = 90; | |
| return not; | |
| } | |
| void okulaKayitOl() {} | |
| } | |
| class Ogretmen extends Insan { | |
| late String brans; | |
| late double maas; | |
| late List<Ogrenci> ogrencileri; | |
| atan() {} | |
| } | |
| void main() { | |
| // burada runApp isminde bir fonksiyon çağrılmış | |
| // nerede tanımlı? | |
| runApp(MyApp()); | |
| // oluşturucu-inşa edici method (fonksiyon) => constructor | |
| // bu bir nesne veya class'ın instance'ı | |
| Ogretmen matematikOgretmeni = Ogretmen(); | |
| matematikOgretmeni.dogumYili = 1990; | |
| matematikOgretmeni.isim = "Burak"; | |
| Ogrenci caliskanOgrenci = Ogrenci.nakilOlarakOlustur("Ahmet", "Atatürk Lisesi", 87); | |
| caliskanOgrenci.ortalama = 90; | |
| Ogrenci tembelOgrenci = Ogrenci("Süleyman", "Atatürk Lises"); | |
| tembelOgrenci.ortalama = 75; | |
| } | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Flutter Demo', | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| primarySwatch: Colors.blue, | |
| ), | |
| home: const MyHomePage(title: 'Flutter Demo Home Page'), | |
| ); | |
| } | |
| } | |
| class MyHomePage extends StatefulWidget { | |
| final String title; | |
| const MyHomePage({ | |
| Key? key, | |
| required this.title, | |
| }) : super(key: key); | |
| @override | |
| _MyHomePageState createState() => _MyHomePageState(); | |
| } | |
| class _MyHomePageState extends State<MyHomePage> { | |
| // değişken tanımlama | |
| int _sayi = 0; | |
| void _incrementCounter(int eklenecekSayi) { | |
| setState(() { | |
| // değişkeni tekrar tanımlama veya değiştirme | |
| _sayi = _sayi + eklenecekSayi; | |
| }); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text(widget.title), | |
| ), | |
| body: Center( | |
| child: Column( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: [ | |
| const Text( | |
| 'You have pushed the button this many times:', | |
| ), | |
| Text( | |
| 'Burası da türkçe ' + isim, | |
| ), | |
| Text(isim), | |
| for (String gun in haftaninGunleri) Text(gun), | |
| const Icon( | |
| Icons.beach_access, | |
| color: Colors.blue, | |
| size: 36.0, | |
| ), | |
| // değişkeni kullanma (using) veya fonksiyonsa çağırma (calling) | |
| Text( | |
| '$_sayi', | |
| style: Theme.of(context).textTheme.headline4, | |
| ), | |
| TextButton( | |
| onPressed: () { | |
| _incrementCounter(-3); | |
| }, | |
| child: const Text("3'er azalt"), | |
| ), | |
| ], | |
| ), | |
| ), | |
| floatingActionButton: FloatingActionButton( | |
| onPressed: () { | |
| // 89. satırda tanımlanan fonksiyonu çağır | |
| _incrementCounter(5); | |
| }, | |
| tooltip: 'Increment', | |
| child: const Icon(Icons.add), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment