Skip to content

Instantly share code, notes, and snippets.

Avatar

Pascal Welsch passsy

View GitHub Profile
@passsy
passsy / README.md
Last active Jul 24, 2020
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 Jun 17, 2020
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 Apr 23, 2020
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 Feb 3, 2020
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 Dec 29, 2019
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 Dec 12, 2019
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
@passsy
passsy / deep_pick.dart
Created Sep 27, 2019
Sample how to use deep_pick to parse json in dart
View deep_pick.dart
import 'dart:convert';
import 'package:deep_pick/deep_pick.dart';
import 'package:http/http.dart' as http;
Future<void> main() async {
/// Request data from a json API
final response = await http.get("https://pokeapi.co/api/v2/pokemon/1");
final json = jsonDecode(response.body);
@passsy
passsy / main.dart
Created Jul 20, 2019
Flutter ListView with fixed header expanding below system navigation
View main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
@passsy
passsy / main.dart
Last active May 13, 2019
Missing compile time check
View main.dart
class Apple {}
class Banana {}
List<Apple> bag([List<Apple> apples]) => apples ?? <Banana>[];
void main() {
// ok
final bag1 = bag([Apple()]);
print(bag1);
You can’t perform that action at this time.