Skip to content

Instantly share code, notes, and snippets.

Avatar

Pascal Welsch passsy

View GitHub Profile
@passsy
passsy / main.dart
Created December 2, 2021 13:59
Example of a stacked card list in flutter using Slivers
View main.dart
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
View main.dart
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
View const_uri.dart
// @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 July 24, 2020 19:57
How to use xrechnung-visualization
View README.md

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
View main.dart
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
View main.dart
void main() {
final Object something = TypeA();
something.matchTypes({
TypeA : () => print("found A"),
TypeB : () => print("found B"),
});
}
View _README.md

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
View run_coverage.sh
#!/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
View main.dart
void main() {
final String name = "Adam";
print("=== ?? ===");
// does not execute defaultValue()
print(name ?? defaultValue());
print("=== orDefault ===");
// executes defaultValue()
print(name.orDefault(defaultValue()));
@passsy
passsy / lcd.md
Created December 12, 2019 12:32
LCD Flutter Dojo
View lcd.md

Number to LCD Kata

Kotlin coding dojo no. 8: convert a given integer number to a LCD style number, see Part 1 of NumberToLCDKata

    0123456789
         
         
         |
         V