Skip to content

Instantly share code, notes, and snippets.

View lukepighetti's full-sized avatar
🦞

Luke Pighetti lukepighetti

🦞
View GitHub Profile
@lukepighetti
lukepighetti / Fastfile
Last active August 22, 2022 08:17
How I build and release Flutter side projects on iOS https://twitter.com/luke_pighetti/status/1530156415611969537
default_platform(:ios)
APPLE_ISSUER_ID = ENV["APPLE_ISSUER_ID"]
APPLE_KEY_CONTENT = ENV["APPLE_KEY_CONTENT"]
APPLE_KEY_ID = ENV["APPLE_KEY_ID"]
DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"]
DEVELOPER_APP_IDENTIFIER = ENV["DEVELOPER_APP_IDENTIFIER"]
GIT_AUTHORIZATION = ENV["GIT_AUTHORIZATION"]
GITHUB_RUN_NUMBER = ENV["GITHUB_RUN_NUMBER"]
PROVISIONING_PROFILE_SPECIFIER = ENV["PROVISIONING_PROFILE_SPECIFIER"]
@lukepighetti
lukepighetti / main.dart
Last active May 25, 2022 11:22
How do you ONLY vertically align in Flutter?
import 'package:flutter/material.dart';
main() {
runApp(
const MaterialApp(
home: Scaffold(
body: Center(
child: SizedBox(
height: 50,
child: DecoratedBox(
@lukepighetti
lukepighetti / cupertino_rectangle_border.dart
Last active May 24, 2022 01:13
Superellipse shape and clipper for high fidelity rounded rectangles on iOS
// FROM https://github.com/flutter/flutter/pull/27523
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math' as math;
import 'dart:ui' as ui;
// ignore_for_file: implementation_imports
import 'package:provider/provider.dart';
extension ProviderStoreBuildContextX on BuildContext {
/// Read the store once, doesn't subscribe a BuildContext to update.
AppStore readStore() => read<AppStore>();
/// Watch the store by subscribing to a BuildContext.
AppStore watchStore() => watch<AppStore>();
/// Select a piece of the store, subscribing a BuildContext to update only
{
"feature_a": {
"enabled": true
},
"feature_b": {
"on_date": "2022-06-01T12:00:00+0000"
},
"feature_c": {
"for_version": "^4.0.1"
},
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.10">
<resources>
<format id="r1" name="FFVideoFormat4096x2304p5994" frameDuration="1001/60000s" width="4096" height="2304" colorSpace="1-1-1 (Rec. 709)"/>
<media id="r2" name="1 Clip" uid="iK5Ho28dSya0X051zIpRVw" modDate="2022-04-26 17:30:11 -0400">
<sequence format="r1" duration="52850798/60000s" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<spine>
<asset-clip ref="r3" offset="0s" name="Screen Recording 2022-04-26 at 4.45.06 PM" duration="52197145/60000s" format="r4" tcFormat="NDF">
@lukepighetti
lukepighetti / enumerate_main.dart
Last active June 1, 2022 13:02
Simple extension for enumerating lists in Dart, because we don't have for loops that expose element index. https://dartpad.dev/ca3544dc667f6a0a082a925494be71ef
main() {
final list = ['a', 'b', 'c'];
for (final element in list.enumerate()) {
print('${element.value} is at index ${element.index}');
}
}
extension EnumerateIterableX<T> on Iterable<T> {
Iterable<EnumeratedElement<T>> enumerate() sync* {
@lukepighetti
lukepighetti / shared_preferences_container.dart
Last active April 3, 2022 16:49
A simple container for persisting values with custom types in shared preferences
import 'package:shared_preferences/shared_preferences.dart';
typedef SharedPreferencesContainerSave<T> = void Function(
T value, String key, SharedPreferences prefs);
typedef SharedPreferencesContainerRestore<T> = T? Function(
String key, SharedPreferences prefs);
/// A container that makes it easy to store values with [SharedPreferences]
class SharedPreferencesContainer<T> {
@lukepighetti
lukepighetti / logging.dart
Last active March 20, 2022 18:48
YAGNI logging utility
import 'package:flutter/foundation.dart';
/// A tagged logging utility with debug / warn / error severity and custom
/// channels
class Logger {
Logger(this.tag);
final String tag;
static final _channels = <LoggerChannel>{};
@lukepighetti
lukepighetti / main.dart
Last active March 15, 2022 11:51
An example showing how to easily draw a masked collection of Canvas operations or an inner shadow
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override