Skip to content

Instantly share code, notes, and snippets.

View lukepighetti's full-sized avatar
🦞

Luke Pighetti lukepighetti

🦞
View GitHub Profile
@lukepighetti
lukepighetti / index.js
Created December 2, 2018 14:29
Apollo-server with Firebase
// index.js
const admin = require("firebase-admin");
const functions = require("firebase-functions");
const express = require("express");
admin.initializeApp();
const { ApolloServer, gql } = require("apollo-server-express");
// Construct a schema, using GraphQL schema language
@lukepighetti
lukepighetti / main.dart
Last active February 12, 2019 14:52
Convert a list of SNAKE_CASE strings into a Dart enum/map declaration
void main() {
const enumName = "Status";
const text = """
PRE_TRADING, TRADING, POST_TRADING, END_OF_DAY, HALT, AUCTION_MATCH, BREAK
""";
final valueList = _sanitize(text);
final camelList = _camelize(valueList);
print(_buildEnumDeclaration(enumName, camelList));
@lukepighetti
lukepighetti / index.dart
Last active February 18, 2019 14:21
Mixin error
class Cook = Person with AwesomeCookingSkills;
class Person {
final String name;
Person(this.name);
}
mixin AwesomeCookingSkills on Person {
String get bestDish => "$name makes the best chocolate.";
@lukepighetti
lukepighetti / README.md
Last active June 11, 2019 14:28
Simple string router

A simple way to do string based routing using Dart's excellent Uri parser.

  1. Create a Router with routes.
  2. Push routes with strings that contain query parameters, or push the parameters as a map via route arguments.

This is meant to be very simple and allow deep linking, eg: onDeepLink(url)=>Navigator.of(context).pushNamed(url)

@lukepighetti
lukepighetti / login.dart
Created June 11, 2019 20:50
Simple navigator + bottom nav bar example
import 'package:flutter/material.dart';
class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
@override
Widget build(BuildContext context) {
/*
* QR.Flutter
* Copyright (c) 2019 the QR.Flutter authors.
* See LICENSE for distribution and usage details.
*/
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:qr/qr.dart';
import 'painter.dart';
@lukepighetti
lukepighetti / main.dart
Last active July 5, 2019 19:21
Provider to bottomSheet
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<AppState>(
builder: (_) => AppState(),
@lukepighetti
lukepighetti / README.MD
Last active September 11, 2019 20:28
Light Theme Relief Kit
@lukepighetti
lukepighetti / platform_implementations.dart
Last active October 3, 2019 12:49
An idea for "federated" platform packages that gives more power to platform specific packages while still allowing them to provide a consistent API that could be fit easily into an intersection package.
/// Given some `dart:io` method that returns a PlatformType enum
PlatformType get currentPlatform => PlatformType.windows;
enum PlatformType { android, fuschia, iOS, linux, macOS, windows }
/// Intersection package, ie `video_player` exposes a common interface
abstract class PlatformVideoController {
Stream<double> get progress;
Future<void> play();
Future<void> pause();
}
@lukepighetti
lukepighetti / value_observable_builder.dart
Last active October 14, 2019 23:54
Value observable builder
import 'package:rxdart/rxdart.dart';
import 'package:flutter/widgets.dart';
/// A more traditional StreamBuilder style builder method
class ValueObservableBuilder<T> extends StreamBuilder<T> {
ValueObservableBuilder({
Key key,
ValueObservable<T> valueObservable,
AsyncWidgetBuilder<T> builder,
}) : super(key: key, stream: valueObservable, initialData: valueObservable.value, builder: builder);