Skip to content

Instantly share code, notes, and snippets.

View guid-empty's full-sized avatar

guid-empty guid-empty

View GitHub Profile
@guid-empty
guid-empty / main.dart
Created May 7, 2021 09:26
SuccessFailure discussion
void main() {
final result = SuccessFailure<void, void>.success(1);
print(result.success);
print(result.failure);
}
typedef Callback<T> = void Function(T value);
class SuccessFailure<S, F> {
factory SuccessFailure.success([S result = null]) {
@guid-empty
guid-empty / main.dart
Created April 8, 2021 16:12
Implicit Amimations - The game
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 April 8, 2021 13:40
Low Level Raw Animation using canvas and scene
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 February 25, 2021 16:33
Dart.Language.Exceptions
void main() {
try {
int divisionPart = 0;
int someVar = 11;
print(someVar ~/ divisionPart);
} catch (e) {
print('Произошла ошибка $e');
@guid-empty
guid-empty / main.dart
Last active February 25, 2021 16:27
Dart.Language.Exceptions handling
///
/// Error - это фейл, который мы никак не предусматривали.
/// В таких случаях приложение умирает.
/// Exception - это то, что мы закладываем в логике
/// работы нашего приложения.
///
void main() {
try {
int products;
@guid-empty
guid-empty / main.dart
Created February 25, 2021 15:57
Dart.Language.Variables & checking the type
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 February 25, 2021 15:46
Dart.Language.Extentions
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 February 25, 2021 15:39
Dart.Language.Generics & constraints
void main() {}
class OptimizedCollection<T> {
void add(T item) {
item.someUsefulAction();
}
void remove(T item) {
}
}
@guid-empty
guid-empty / main.dart
Last active February 25, 2021 15:37
Dart.Language.Generics & problem
void main() {}
abstract class MyCollectionItem {}
abstract class MyOptimizedCollection {
void add(MyCollectionItem item);
void remove(MyCollectionItem item);
}
abstract class OtherCollectionItem {}