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
Created February 1, 2020 19:47
Flutter Game with Implicit Animations
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
void main() {
A o = A(B(true), B(true), B(true));
print(o);
// т.е. мы вызываем не o.operation(propName) мы делаем o.propName.operation()
o.x.inverse();
print(o);
o.y.inverse();
o.x.truify();
print(o);
}
@misterfourtytwo
misterfourtytwo / difference.dart
Last active July 24, 2020 08:46
dateTime difference
void main() {
// subtract later date from previous for positive values
DateTime a = DateTime(0, 1);
DateTime b = DateTime(0, 2);
print(b.difference(a).inDays);
print(a.difference(b).inDays);
}
@misterfourtytwo
misterfourtytwo / patch_cupertino_navbar.sh
Created November 5, 2020 09:59
flutter patch cupertino navbar to remove blur when setting transparent background
#!/bin/bash
S_suff="/bin/flutter"
S_fh=$(which flutter)
S_fh=${S_fh%"$S_suff"}
S_navbar=${S_fh}"/packages/flutter/lib/src/cupertino/nav_bar.dart"
awk '/(if\ \(backgroundColor.alpha\ \=\= 0xFF\)){1}/ { $0 = "//"$0 }; 1' $S_navbar>S_tmp
mv S_tmp $S_navbar
S_suff=
S_fh=
@misterfourtytwo
misterfourtytwo / singleChildScrollView.dart
Last active February 24, 2021 11:35
singleChildScrollView
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@misterfourtytwo
misterfourtytwo / classes_sandbox.dart
Created March 31, 2021 05:18
sandbox git for checking out dart classes behavior
class SuperClass {
void hello() => print('hello');
void world() {
hello();
print('world!');
print('');
}
}
class SubClass extends SuperClass {
@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();
@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 / 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 / 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) {