Tuesday, December 5, 2023

Ekran genişliğini ve yüksekliğini alma

 

double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;

Container(
  height: screenHeight,
  width: screenWidth,
  color: Colors.white,
  // ...
),

Monday, December 4, 2023

basit bir dugme

 

ElevatedButton(
child: const Text("Hey"),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const SecondRoute()),
);
},

Yeni bir page nasil import edilir



Her page ayri bir dart dosyasinda kodladiginizi varsayalim.


import 'page2.dart';

diger sayfadaki class yukaridaki sekilde import edilmelidir.

Friday, November 11, 2022

Monday, November 7, 2022

Navigator operation requested with a context that does not include a Navigator.

 Before:

 

void main() {
runApp(AnaEkran(),

);
}

After:

void main() {
runApp(MaterialApp(
home: AnaEkran(),
),
);
}
 
https://stackoverflow.com/questions/44004451/navigator-operation-requested-with-a-context-that-does-not-include-a-navigator 

Sunday, November 6, 2022

Rastgele sayı alma

Random

Random is a generator of bool, int or double values.

var intValue = Random().nextInt(10); // Value is >= 0 and < 10.
var doubleValue = Random().nextDouble(); // Value is >= 0.0 and < 1.0.
var boolValue = Random().nextBool(); // true or false, with equal chance

 Reference:

https://api.flutter.dev/flutter/dart-math/dart-math-library.html

 

 

Random rnd;
int min = 5;
int max = 10;
rnd = new Random();
r = min + rnd.nextInt(max - min);
print("$r is in the range of $min and $max");
 
 
//1 ile 5 arasında bir sayı döndür 
import 'dart:math';
int max = 5;
int randomNumber = Random().nextInt(max) + 1;
 
 
int nextInt(int min, int max) => min + _random.nextInt((max + 1) - min);
 
import 'dart:math';

Random rnd = new Random();
// Define min and max value
int min = 1, max = 10;
//Getting range
int num = min + rnd.nextInt(max - min);
print("$num is in the range of $min and $max");   

Ekran genişliğini ve yüksekliğini alma

  double screenWidth = MediaQuery.of(context).size.width; double screenHeight = MediaQuery.of(context).size.height; Container( height: sc...