Skip to content

Instantly share code, notes, and snippets.

View passsy's full-sized avatar

Pascal Welsch passsy

View GitHub Profile
@passsy
passsy / advanced_overlay.dart
Last active October 21, 2024 03:57
A Flutter overlay implementation that allows alligning the overlay freely around the target (button)
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
/// Written by PHNTM GmbH
void main() {
runApp(const AdvancedOverlaySample());
}
@passsy
passsy / main.dart
Created December 2, 2021 13:59
Example of a stacked card list in flutter using Slivers
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(Kata());
}
class Kata extends StatelessWidget {
@override
@passsy
passsy / main.dart
Created October 11, 2021 11:58
Dart CLI, progress indication while awaiting Future
import 'dart:async';
void main() async {
// start future
final future = doHardWork();
// continously post progress
final sub = showProgress().listen((_) {});
// wait for completion
await future;
// stop progress
@passsy
passsy / const_uri.dart
Last active March 16, 2021 00:49
const implemenation of dart:core Uri
// @dart=2.12
/// A const implementation of Uri which crashes at first access in case the uri is invalid
class ConstUri implements Uri {
/// Caches the static parsed uri
///
/// The parsed uri can't be a mutable member field because that's not allowed for const classes
static final _cache = <String, Uri>{};
const ConstUri(String uri) : _uri = uri;
@passsy
passsy / README.md
Last active October 25, 2024 15:04
How to use xrechnung-visualization

How to use xrechnung-visualization

1. Install Ant

Install brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Then install ant using brew

@passsy
passsy / main.dart
Created June 17, 2020 10:29
wrap_content match_parent in Flutter
import 'package:flutter/material.dart';
Future<void> main() async {
runApp(Builder(
builder: (context) => const MyApp(),
));
}
class MyApp extends StatelessWidget {
const MyApp({
@passsy
passsy / main.dart
Created April 23, 2020 19:20
Type switch case
void main() {
final Object something = TypeA();
something.matchTypes({
TypeA : () => print("found A"),
TypeB : () => print("found B"),
});
}

Interactive CLI in Dart

Screen-Recording-2020-03-03-22-55-27

Example how to build a interactive CLI application in Dart

@passsy
passsy / run_coverage.sh
Created February 3, 2020 01:05
Run dart code coverage
#!/bin/sh
# Usage: ./tool/run_coverage.sh test/all_tests.dart
(pub global list | grep coverage) || {
# install coverage when not found
pub global activate coverage
}
pub global run coverage:collect_coverage \
@passsy
passsy / main.dart
Created December 29, 2019 20:01
Comparison between ?? and a orDefault method
void main() {
final String name = "Adam";
print("=== ?? ===");
// does not execute defaultValue()
print(name ?? defaultValue());
print("=== orDefault ===");
// executes defaultValue()
print(name.orDefault(defaultValue()));