Skip to content

Instantly share code, notes, and snippets.

View AbdullohBahromjonov's full-sized avatar
🇺🇿
Based In Uzbekistan

Abdulloh Bahromjonv AbdullohBahromjonov

🇺🇿
Based In Uzbekistan
View GitHub Profile
const myAge = 15;
const isTeenager = (13 >= 19);
const maryAge = 30;
const bothTeenagers = (myAge == isTeenager) && (maryAge == isTeenager);
const reader = 'Abdulloh';
const ray = 'Ray Wenderlich';
const rayIsReader = (ray == reader);
void main() {
print(bothTeenagers);
@AbdullohBahromjonov
AbdullohBahromjonov / Interfaces.dart
Created May 2, 2022 08:00
Dart "extends" and "implements" interfaces
abstract class Person {
String get name;
int get age;
void speak(String name, int age);
void walk() {
print('walk');
}
}
class Person {
final String name;
final int age;
Person(this.name, this.age);
Person.born() : name = 'Abdulloh', age = 15;
factory Person.zero() {
final one = Person.born().age-7;
enum Weekdays {
monday,
tuesday,
wednesday,
thursday,
friday,
saturday,
sunday
}
var number1 = 20;
var number2 = 10;
void main() {
final plus = number1+number2;
final minus = number1-number2;
final multiply = number1*number2;
final devision = number1/number2;
final devisionWithReminder = number1~/(number2+2);
final reminderOfDevision = number1%(number2+2);
@AbdullohBahromjonov
AbdullohBahromjonov / Parsing.dart
Last active April 27, 2022 17:08
Parsing one data type to another
void main() {
//final one = int.parse('one'); //error
final two = double.parse('2.2'); //successful
final three = int.tryParse('one'); //null
final four = double.tryParse('4.5'); //successful
final one = int.parse('3');
print('''
$two
$three
String? nullString = 'Abdulloh';
void main() {
nullString = null;
print (isNullString(nullString));
}
bool isNullString(String? someNullablesString) {
if (someNullablesString == null) {
@AbdullohBahromjonov
AbdullohBahromjonov / Data Types.dart
Last active April 26, 2022 18:42
Dart simple data types
int number = 2;
num number2 = 2.0;
double number3 = 3;
String str = 'Abdulloh';
final list = [1, 2, 3];
final map = {1: 'one', 2: 'two', 3: 'three'};
final mapValue = map[1];