Skip to content

Instantly share code, notes, and snippets.

@malibayram
Last active December 13, 2020 17:19
Show Gist options
  • Save malibayram/8c9c87f0405b6a8404bcf4787fc65c58 to your computer and use it in GitHub Desktop.
Save malibayram/8c9c87f0405b6a8404bcf4787fc65c58 to your computer and use it in GitHub Desktop.
13 Aralık 2020'de yazdığımız kodlar
// 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.
import 'package:flutter/material.dart';
// slayt linki: https://docs.google.com/presentation/d/1tuiMbSNSipgOyc-bp-_sTh3u7aCj0Wo07KV7eDAoDuM/
// önceki ve çalışmayacak olan link: https://dartpad.dev/b6409e10de32b280b8938aa75364fa7b
// çalışan link
// 1. Sıralı ve hepsi zorunlu
// 2. Sıralı ve serbest
// 3. Hem Sıralı değil, hem serbest dolayısıyla değişkenleri gönderirken isimlerini belirtmeniz gerekiyor
// 4. Sıralı değil ama zorunlu
// 1. dışa değer üreten fonksiyonlar
// 2. ve yapmayanlar
void fonksiyon(int degisken1) {}
class Madde {
int agirlik;
}
class NesneSinif extends Madde {
String ozellik1 = "Mehmet";
String ozellik3 = "Ali";
int ozellik2;
NesneSinif({/* @required */ String deg1, int deg2}) {
ozellik1 = deg1;
ozellik2 = deg2;
String isim = "$ozellik1 $ozellik3";
print(isim);
}
}
NesneSinif birinciNesne = NesneSinif(deg2: 32, deg1: "");
void main() {
runApp(BenimUygulamam());
}
// Stateful ve Stateless
class BenimUygulamam extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: true,
theme: ThemeData(
primarySwatch: Colors.orange,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
_counter = _counter + 2;
// cok uzun sürecek sürecek bir işlem()
asenkronIslem();
// if (_counter % 4 == 0)
setState(() {});
}
Future<String> asenkronIslem() async {
await Future.delayed(Duration(seconds: 3));
_counter = _counter + 1;
setState(() {});
return "";
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title ?? "Başlık gönderilmedi",
style: TextStyle(color: Colors.white)),
),
drawer: Drawer(
child: Column(
children: [
],
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment