Skip to content

Instantly share code, notes, and snippets.

View AlexKenbo's full-sized avatar
🎯
We will write a chat app =)

ALEKSANDR VASILEV AlexKenbo

🎯
We will write a chat app =)
View GitHub Profile
@AlexKenbo
AlexKenbo / main.dart
Created March 9, 2020 05:57
Stream - 1
import 'dart:async';
void main() {
var streamController = StreamController();
streamController.stream.listen(
(data) => print('Got eem! $data'),
onError: (err) => print('Got an error! $err'),
onDone: () => print('Mission complete!'),
cancelOnError: false,
@AlexKenbo
AlexKenbo / main.dart
Created February 9, 2020 15:22
flutter keys part 6
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(new MaterialApp(home: PositionedTiles()));
}
@AlexKenbo
AlexKenbo / main.dart
Created February 9, 2020 15:10
flutter keys part 4
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(new MaterialApp(home: PositionedTiles()));
}
@AlexKenbo
AlexKenbo / main.dart
Created February 8, 2020 17:59
When to use keys, part 2 - statefull no key
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(new MaterialApp(home: PositionedTiles()));
}
class PositionedTiles extends StatefulWidget {
@AlexKenbo
AlexKenbo / main.dart
Created February 8, 2020 13:43
When to use keys, part 2 - statefull
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(new MaterialApp(home: PositionedTiles()));
}
@AlexKenbo
AlexKenbo / main.dart
Created February 8, 2020 09:49
When to use keys, part 1 - stataless
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(new MaterialApp(home: PositionedTiles()));
}
@AlexKenbo
AlexKenbo / main.dart
Created January 31, 2020 16:15
Flutter design patterns - singleton
import 'package:flutter/material.dart';
abstract class ExampleStateBase {
@protected
String initialText;
@protected
String stateText;
String get currentText => stateText;
void setStateText(String text) {
@AlexKenbo
AlexKenbo / main.dart
Last active January 30, 2020 08:40
Singleton (design pattern). Что такое _приватный конструктор?
void main() {
Map<String,dynamic> bob = {
'name': 'Bob',
};
Map<String,dynamic> bobLike = {
'name': 'Bob',
};
if(bob == bobLike) {
@AlexKenbo
AlexKenbo / main.dart
Created January 30, 2020 06:33
Присвоение значений закрытым переменным класса в конструкторе
class Student{
var _id;
var _name;
Student({this._id, this._name}); // error - имена параметров не могут начинаться с _
void set id(int id) => _id = id;
void set name(String name) => _name = name;
}
@AlexKenbo
AlexKenbo / functional.dart
Created November 2, 2019 05:48
Functional programming in dart
String scream(int length) => "A${'a' * length}h!";
main() {
final values = [1, 2, 3, 5, 10, 50];
//Normal not functional:
print('Normal, not functional: ');
for (var length in values) {
print(scream(length));
}