Skip to content

Instantly share code, notes, and snippets.

View filiph's full-sized avatar
:shipit:

Filip Hracek filiph

:shipit:
View GitHub Profile
@filiph
filiph / normalized_double.dart
Created May 3, 2024 06:56
An idea for an extension type for normalized floating point values
/// A value that is guaranteed to be normalized (between `0.0` and `1.0`).
///
/// Might be useful to avoid confusion in math-heavy code.
/// For example, a function might expect some of its arguments
/// to be normalized real numbers. Instead of just documenting
/// it in API docs or checking it at runtime, we can express it
/// through the parameter's static type.
///
/// This is an extension type. The nice thing about those is that
/// they have zero runtime overhead.
@filiph
filiph / main.dart
Last active October 11, 2022 13:21
Fading Scroller (naive implementation in Flutter)
// The accompanying tweet (incl. video) is here:
// https://twitter.com/filiphracek/status/1494213873422974978
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
void main() {
print("Hello DartPad");
}
@filiph
filiph / index.html
Last active April 15, 2021 23:22
Combine lists
<h1 id="header">Combinations</h1>
<p>This tiny tool will combine any number of lists, combining every option with every other option. Separate lists by a blank line.</p>
<textarea id="input" rows=20 cols=40>
In college, I had
good grades,
bad grades,
@filiph
filiph / main.dart
Created March 31, 2021 19:54
Scrollbar widget of the week
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@filiph
filiph / main.dart
Last active October 11, 2022 13:23
Human Life Counter
// This now lives in https://github.com/filiph/human-life/blob/main/lib/main.dart as source
// and at https://filiph.github.io/human-life/ as an app.
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(HumanLifeApp());
}
@filiph
filiph / main.dart
Created February 19, 2021 04:36
Unbounded error app
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@filiph
filiph / rotated_box.dart
Created January 6, 2021 20:17
RotatedBox widget of the week sample
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@filiph
filiph / main.dart
Created August 8, 2020 02:31
SnackBar floating regression
import 'package:flutter/material.dart';
void main() => runApp(SnackBarDemo());
class SnackBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SnackBar Demo',
home: Scaffold(
@filiph
filiph / main.dart
Created August 8, 2020 01:45
SnackBar regression
import 'package:flutter/material.dart';
void main() => runApp(SnackBarDemo());
class SnackBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SnackBar Demo',
home: Scaffold(