Skip to content

Instantly share code, notes, and snippets.

Avatar

guid-empty guid-empty

View GitHub Profile
@guid-empty
guid-empty / main.dart
Created Apr 8, 2021
Implicit Amimations - The game
View main.dart
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
double randomBorderRadius() => Random().nextDouble() * 64;
Color randomColor() {
@guid-empty
guid-empty / main.dart
Created Apr 8, 2021
Low Level Raw Animation using canvas and scene
View main.dart
import 'dart:ui';
import 'package:flutter/painting.dart';
void main() {
window.onBeginFrame = beginFrame;
window.scheduleFrame();
}
///
/// See more details on https://fiddle.skia.org/c/@shapes
@guid-empty
guid-empty / main.dart
Created Feb 25, 2021
Dart.Language.Exceptions
View main.dart
void main() {
try {
int divisionPart = 0;
int someVar = 11;
print(someVar ~/ divisionPart);
} catch (e) {
print('Произошла ошибка $e');
@guid-empty
guid-empty / main.dart
Last active Feb 25, 2021
Dart.Language.Exceptions handling
View main.dart
///
/// Error - это фейл, который мы никак не предусматривали.
/// В таких случаях приложение умирает.
/// Exception - это то, что мы закладываем в логике
/// работы нашего приложения.
///
void main() {
try {
int products;
@guid-empty
guid-empty / main.dart
Created Feb 25, 2021
Dart.Language.Variables & checking the type
View main.dart
void main() {
num value = 10;
bool isObject = value is Object;
print(value.runtimeType);
print(isObject);
Object obj = value as Object;
print(obj.runtimeType);
@guid-empty
guid-empty / main.dart
Created Feb 25, 2021
Dart.Language.Extentions
View main.dart
void main() {
for (final current in StringIterable('Hello World!')) {
print(current);
}
// for (final current in 'Hello World!'.toIterable()) {
// print(current);
// }
}
@guid-empty
guid-empty / main.dart
Created Feb 25, 2021
Dart.Language.Generics & constraints
View main.dart
void main() {}
class OptimizedCollection<T> {
void add(T item) {
item.someUsefulAction();
}
void remove(T item) {
}
}
@guid-empty
guid-empty / main.dart
Last active Feb 25, 2021
Dart.Language.Generics & problem
View main.dart
void main() {}
abstract class MyCollectionItem {}
abstract class MyOptimizedCollection {
void add(MyCollectionItem item);
void remove(MyCollectionItem item);
}
abstract class OtherCollectionItem {}
@guid-empty
guid-empty / main.dart
Created Feb 25, 2021
Dart.Language.Classes & Implementation the interfaces
View main.dart
void main() {
final entity = Entity();
print(entity is Disposable);
print(entity is Clonable);
print(entity is Comparable);
print(entity is BaseEntity);
// entity.
}