Skip to content

Instantly share code, notes, and snippets.

View misterfourtytwo's full-sized avatar
🍌

Aliaksei Tratseuski misterfourtytwo

🍌
View GitHub Profile
@misterfourtytwo
misterfourtytwo / main.dart
Last active August 31, 2023 08:50
different loadable element approaches
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
createState() => _MyAppState();
}
@misterfourtytwo
misterfourtytwo / solution.dart
Last active July 7, 2023 17:04
Yandex interview algo task: find longest ascending/descending segment of an array
/*
Дан массив чисел a_1, a_2, ..., a_n .
Необходимо найти монотонный подотрезок (то есть строго убывающий или строго возрастающий) максимальной длины и
вернуть пару индексов его начала и конца.
*/
void main() {
final tests = [
[1, 1], // -> {1, 3}
[2, 7, 5, 4, 4, 3], // -> {1, 1} or {0, 0}
@misterfourtytwo
misterfourtytwo / user_subclasses_with_mixin_components.dart
Last active March 17, 2023 06:47
Decompose different user subfeatures into mixins with freezed.
import 'package:freezed_annotation/freezed_annotation.dart';
part 'user.freezed.dart';
abstract class IUserBase {
int? get id;
}
enum UserStatus {
normal,
pro,
@misterfourtytwo
misterfourtytwo / method_is_not_getter.dart
Last active February 23, 2023 23:30
function tear-off behaves like getter, but is actually syntactic sugar, while function method declaration and getter are incompatible language tokens
void p(String x) => print(x);
typedef MyFunc = void Function(String);
abstract class A {
MyFunc? get t;
const A();
}
class B implements A {
@override
@misterfourtytwo
misterfourtytwo / crossAxisAlignment.start vs stretch
Last active January 11, 2023 17:52
crossAxisAlignment.start vs stretch
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@misterfourtytwo
misterfourtytwo / progressbar_border.dart
Created February 3, 2022 11:58
add border to progressbar around its content
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@misterfourtytwo
misterfourtytwo / circular_menu_widget.dart
Created November 4, 2021 11:11
circular menu widget example
import 'dart:math' as math;
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@misterfourtytwo
misterfourtytwo / wrap.dart
Last active October 25, 2021 09:08
wrap with padding
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@misterfourtytwo
misterfourtytwo / not_a_const.dart
Created April 15, 2021 15:35
constant class field not const
const strings = const Strings();
class Strings {
const Strings();
final Feature1 feature1 = const Feature1();
// final Feature2 feature2 = const Feature2();
}
class Feature1 {
const Feature1({
@misterfourtytwo
misterfourtytwo / adaptive_theme_switcher.dart
Created April 13, 2021 11:19
adaptive theme switcher example
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();