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 / main.dart
Last active January 30, 2020 23:55
Perception
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Perception is Everything',
home: MyHomePage(),
@filiph
filiph / main.dart
Created January 9, 2020 18:55
Use curves other than linear
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
@filiph
filiph / list_wheel_scroll_view.dart
Created January 6, 2020 19:39
list_wheel_scroll_view
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
@filiph
filiph / main.dart
Created December 20, 2019 06:44
Happy Holidays from Filip
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@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);
}
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() => runApp(
ChangeNotifierProvider<AppStateManager>.value(
value: AppStateManager(),
child: MyApp(),
),
);
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],
@filiph
filiph / main.dart
Last active July 11, 2021 10:22
A functional way to capitalize each word in a sentence (a.k.a. Title Case). This is not efficient -- use something like string_scanner if you need to run this in a tight loop.
main() {
var city = "new york";
print(titleCase(city));
}
/// Inefficient way of capitalizing each word in a string.
String titleCase(String text) {
if (text.length <= 1) return text.toUpperCase();
var words = text.split(' ');
var capitalized = words.map((word) {
@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) {
@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 ...