Skip to content

Instantly share code, notes, and snippets.

View s0nerik's full-sized avatar
🇺🇦

Alex Isaienko s0nerik

🇺🇦
View GitHub Profile
@s0nerik
s0nerik / adjust_pan.dart
Last active August 26, 2020 21:25
A widget that mimics Android's `adjustPan` windowSoftInputMode
import 'dart:async';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
typedef AdjustPanChildBuilder = Widget Function(EdgeInsetsGeometry padding);
/// A widget that forces the same behavior as
/// Android's `adjustPan` windowSoftInputMode.
///
@s0nerik
s0nerik / preprocess.py
Created June 4, 2020 01:10
Preprocess SVG files for svg_flutter
#!/usr/bin/env python3
# coding=utf8
import re
import io
import os
import sys
regex = r"(<[^>]+href=\"#([^>]+)\"[^<]*>)[^\3]*(<[^>]+id=\"\2\"[^<]*>)"
pattern = re.compile(regex)
@s0nerik
s0nerik / main.dart
Created May 14, 2020 14:09
Dart sucks
void main() {
final iterable = [1].map((x) => x * 2);
x(iterable);
}
void x(List<int> ints) {
print('Hello');
}
@s0nerik
s0nerik / main.dart
Created May 13, 2020 14:13
Dart const List
main() {
final list1 = const <int>[];
final list2 = const <int>[];
print(identical(list1, list2));
list1.add(666);
print(list1[0]);
print(list2[0]);
}
@s0nerik
s0nerik / main.dart
Last active April 24, 2020 18:34
Color calc
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@s0nerik
s0nerik / _flutter_version.md
Last active March 28, 2020 02:31
Flutter version changer

How it works

This script creates/maintains a symlink to the Flutter SDK of choice. It provides a way to quickly switch Flutter SDK version globally for the whole system.

How to use it

  1. Put flutter_version.sh into your home folder
  2. Run chmod +x flutter_version.sh
  3. Replace ~/Documents/SDKs on line 16 with a path to the folder where you want to store the Flutter SDK versions
  4. Download and put whichever versions of flutter you'd like to switch between into <SDKs path>/flutter_versions folder and name them conveniently. Something like 1.12 and 1.16_beta will work well.
  5. Add /flutter/bin into PATH
@s0nerik
s0nerik / clear.sh
Created November 14, 2019 19:51
Clear dart analysis server cache (makes IDE suggestions faster)
rm -rf ~/.dartServer/.analysis-driver
@s0nerik
s0nerik / update_nested_packages.sh
Created October 24, 2019 10:52
Flutter: update packages for all nested flutter projects
find . -name "pubspec.yaml" -execdir sh -c 'rm pubspec.lock; flutter packages get' \;
@s0nerik
s0nerik / commands.md
Created October 10, 2019 10:18
Useful imagemagick commands for developers

Tint icon:

convert icon.png -fill <color> -colorize 100 out.png
@s0nerik
s0nerik / app.gradle.kts
Last active May 16, 2023 14:46
Android multi-module Gradle setup example
plugins {
id("com.android.application")
}
android {
defaultConfig {
applicationId = "com.example.task"
versionCode = 1
versionName = "1.0"
}