Skip to content

Instantly share code, notes, and snippets.

vishna / syntax_highlighter.dart
Last active March 1, 2021 11:47 — forked from X-Wei/syntax_highlighter.dart
syntax-highlighter for flutter_markdown (adopted from flutter_gallery) + nullsafety + range error fix
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart' show SyntaxHighlighter;
import 'package:string_scanner/string_scanner.dart';
class SyntaxHighlighterStyle {
vishna / carousel.dart
Created July 21, 2020 17:41 — forked from slightfoot/carousel.dart
Scrolling Carousel with centered variable width items and snapping - By Simon Lightfoot - 20/07/2020
vishna / navigator_observer_delegate.dart
Created February 4, 2020 13:31
// utility class so that you don't have to extend from [NavigatorObserver] but rather
/// pass the function you want
class NavigatorObserverDelegate extends NavigatorObserver {
vishna / widget_tester_rich_edit.dart
Created February 3, 2020 14:31
WidgetTester RichEdit Extension - find a piece of text, e.g. tap a link in the text
/// found nothing better than this
/// sooo...
extension WidgetTesterRichEditExtension on WidgetTester {
Iterable<InlineSpan> findTextSpans(
Finder richTextFinder, bool Function(InlineSpan) predicate) {
final richText = widget<RichText>(richTextFinder);
expect(richText.text, isInstanceOf<TextSpan>());
final TextSpan innerText = richText.text;
return innerText.children.where(predicate);
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)
// MIT License
// Copyright (c) 2019 Lukasz Wisniewski
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
# 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 ""
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 January 23, 2022 15:49
Suspened Variable in Kotlin - works kinda lateinit but if your variable is late, it will make you wait rather than crash
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 -> {
vishna / suspend_var_actorless.kt
Last active June 18, 2019 09:44
Suspended Variable
* 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) {