Skip to content

Instantly share code, notes, and snippets.

@killermonk
killermonk / iterable_index_map.dart
Created September 27, 2022 15:29
How to map with an index in dart
// https://pub.dev/packages/quiver
import 'package:quiver/iterables.dart';
// Map with index on an individual basis
enumerate(['a', 'b', 'c']).map((e) {
return '${e.index}: ${e.value}';
});
// => ['0: a', '1: b', '2: c']
@killermonk
killermonk / routes.dart
Last active January 6, 2018 11:47
An example of routing
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
import sys
OLD_DEDUCTION = 6350
OLD_BRACKET = {
0: {
"rate": 0.10,
},
9325: {
"rate": 0.15,
},
@killermonk
killermonk / DoubleSpaceToPeriodInputFormatter.dart
Created October 19, 2017 17:26
A very basic input formatter that adds a period if you hit the space bar twice
import 'package:flutter/services.dart';
class DoubleSpaceToPeriodInputFormatter extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
// This is pretty lazy and will just keep appending periods if you keep hitting space
if (newValue.text.endsWith(' ')) {
final String withPeriod = newValue.text.substring(0, newValue.text.length - 2) + '. ';
return newValue.copyWith(text: withPeriod);
}

Keybase proof

I hereby claim:

  • I am killermonk on github.
  • I am killermonk (https://keybase.io/killermonk) on keybase.
  • I have a public key ASB5zUVLysmT6Jyst-noLt60PXKknYgaxjdqyp9v8AX31wo

To claim this, I am signing this object: