Skip to content

Instantly share code, notes, and snippets.

Łukasz Wiśniewski vishna

Block or report user

Report or block vishna

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View flutter_path_activity.kt
import // there are two FlutterActivities :|
import io.flutter.plugins.GeneratedPluginRegistrant // this is not seen by IntelliJ by works ¯\_(ツ)_/¯
typealias FlutterCallback = (methodCall: MethodCall, result: MethodChannel.Result) -> Unit
class FlutterPathActivity : FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
infix fun String.handles(callHandler: FlutterCallback) {
MethodChannel(flutterEngine.dartExecutor, this).setMethodCallHandler(callHandler)
View isolates_workaround.dart
import 'dart:async';
import 'package:flutter_driver/flutter_driver.dart';
/// Workaround for bug:
/// ```
/// FlutterDriver driver;
# Makes the bash script to print out every command before it is executed except echo
trap '[[ $BASH_COMMAND != echo* ]] && echo $BASH_COMMAND' DEBUG
echo "Executing steps to repro issue #37852"
echo ""
View my_flutter_pubspec.yaml
name: my_flutter
description: A new flutter module project.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at
vishna / suspend_var.kt
Last active Jun 18, 2019
Suspened Variable in Kotlin - works kinda lateinit but if your variable is late, it will make you wait rather than crash
View suspend_var.kt
class SuspendedVariable<T>(var scope: CoroutineScope? = GlobalScope) {
private var actor = scope?.actor<Op<T>> {
var value : T? = null
val deferrals = mutableListOf<CompletableDeferred<T>>()
try {
for (message in channel) {
when (message) {
is Op.Set -> {
View suspend_var_actorless.kt
* kinda like `lateinit var` but if it's really late it will make you wait rather than crash.
class SuspendedVariable<T> {
private val callbacks = mutableListOf<((T) -> Unit)>()
private var value: T? = null
fun set(t: T) {
value = t
if (t != null) {
View MainActivity.kt
import android.content.Intent
import android.os.Bundle
import android.util.Log
private const val tag = "2ndShare"
* 1) Clear all the apps
* 2) Go to Google Photos, share image to this app
vishna / doOnNextLayout.kt
Created Nov 23, 2018
View doOnNextLayout.kt
inline fun <T : View> T.doOnNextLayout(crossinline action: (view: T) -> Unit) {
addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
override fun onLayoutChange(
view: View,
left: Int,
top: Int,
right: Int,
bottom: Int,
oldLeft: Int,
View better-safe-than-sorry.kt
inline fun <T> safe(block: () -> T?) : T? {
return try {
} catch (t: Throwable) {
null // ¯\_(ツ)_/¯
vishna / debounce-broadcast.kt
Created Nov 5, 2017
Debounce input from an EditText and relay to a TextView with a timeout.
View debounce-broadcast.kt
package me.vishna.kdebounce
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
import kotlinx.coroutines.experimental.*
You can’t perform that action at this time.