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 / spanify.dart
Last active June 1, 2017 22:36
A tool used for CSS-fading in a site without any client-side scripting
import 'dart:io';
import 'dart:math';
import 'package:html/dom.dart';
import 'package:html/parser.dart';
import 'package:markdown/markdown.dart' as md;
main(args) {
var mdSource = new File(args.single).readAsStringSync();
var html = md.markdownToHtml(mdSource);
@filiph
filiph / are_we_there_yet.sh
Created September 20, 2018 21:00
A script that tells you whether a commit has landed to which Flutter branch.
#!/usr/bin/env bash
DEFAULT_HASH=76468dd
if [ -z "$1" ]
then
echo "You can provide the commit hash you're interested in as argument."
echo "Defaulting to $DEFAULT_HASH."
HASH=$DEFAULT_HASH
else
@filiph
filiph / are_we_there_yet.sh
Last active September 20, 2018 23:33
A script that tells you whether a commit has landed to any of the Flutter channels (`master`, `dev` and `beta`). Useful when you're waiting to use a feature or remove a workaround to a bug.
#!/usr/bin/env bash
set -o vi
# Change this accordingly.
# You may have github.com/flutter/flutter named as "upstream".
REMOTE_NAME=origin
# The hash we search for when no argument is given.
DEFAULT_HASH=76468dd
@filiph
filiph / main.dart
Created November 21, 2018 22:44
Hot reload time out
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:sliver_fbs/src/names.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@filiph
filiph / main.dart
Created November 30, 2018 00:46
ScopedModel counter app
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
void main() {
// The app state.
final myModel = CounterModel(42);
// A timer, to simulate updates coming from outside the app.
@filiph
filiph / main.dart
Last active December 20, 2018 00:54
The starter Flutter app rewritten using ScopedModel
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
void main() {
// Initialize the model. Can be done outside a widget, like here.
var counter = Counter();
// Just because we can: wait five seconds after the start of the app ...
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
const List<List<int>> _pixels = [
[1, 1, 1, 1, 0, 0, 1, 1, 0],
[1, 0, 0, 0, 0, 1, 0, 0, 1],
[1, 1, 1, 0, 0, 1, 0, 0, 1],
[0, 0, 0, 1, 0, 1, 0, 0, 1],
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() => runApp(
ChangeNotifierProvider<AppStateManager>.value(
value: AppStateManager(),
child: MyApp(),
),
);
@filiph
filiph / function_no_typedef.dart
Created August 28, 2019 09:07
How to define function signature without a typedef
main() {
takesFunction((x) => "result: $x");
}
void takesFunction(String Function(int) callback) {
final result = callback(42);
print(result);
}
@filiph
filiph / main.dart
Last active September 11, 2019 00:52
Implementation of the ring of circles in Flutter. Initial inspiration: https://twitter.com/InfinityLoopGIF/status/1101584983259533312. Kotlin implementation: https://gist.github.com/alexjlockwood/e3ff7b9a05dd91ff0955b90950bf7ee5
import 'package:flutter/material.dart';
import 'package:ring_of_circles/src/widget.dart';
/// Just the app. Nothing to see here, except the code for changing
/// the number of circles (`n`).
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {