Skip to content

Instantly share code, notes, and snippets.

@jmagman
jmagman / minimum_frame_duration_migration.dart
Created March 9, 2022 00:52
CADisableMinimumFrameDurationOnPhone Info.plist migration for https://github.com/flutter/flutter/pull/94509
// Copyright 2014 The Flutter 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 '../../base/file_system.dart';
import '../../base/logger.dart';
import '../../base/project_migrator.dart';
import '../../xcode_project.dart';
// Add CADisableMinimumFrameDurationOnPhone to the Info.plist.
@jogboms
jogboms / main.dart
Created February 25, 2022 18:02
Circular mood picker
import 'dart:math' as math;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
const primaryColor = Color(0xFF080B21);
@DavidWells
DavidWells / javascript-proxy-as-rest-client.js
Last active May 12, 2024 14:24
Using a javascript proxy as low code REST client
/* Using a JavaScript proxy for a super low code REST client */
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3
// also see https://github.com/fastify/manifetch
// also see https://github.com/flash-oss/allserver
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {

Cheat sheet: Arrays

JavaScript Arrays are a very flexible data structure and used as lists, stacks, queues, tuples (e.g. pairs), etc. Some

Using Arrays

Creating Arrays, reading and writing elements:

@passsy
passsy / main.dart
Created December 2, 2021 13:59
Example of a stacked card list in flutter using Slivers
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(Kata());
}
class Kata extends StatelessWidget {
@override
@creativecreatorormaybenot
creativecreatorormaybenot / OpacityHex.markdown
Last active March 14, 2025 09:43 — forked from passiondroid/OpacityHex.markdown
Opacity Percentage to Flutter Opacity Hex Color code

Flutter uses hexadecimal ARGB values for colors, which are formatted as const Color(0xAARRGGBB). That first pair of letters, the AA, represent the alpha channel. You must convert your decimal opacity values to a hexadecimal value. Here are the steps:

Alpha Hex Value Process

  • Take your opacity as a decimal value and multiply it by 255. So, if you have a block that is 50% opaque the decimal value would be .5. For example: .5 x 255 = 127.5

  • The fraction won't convert to hexadecimal, so you must round your number up or down to the nearest whole number. For example: 127.5 rounds up to 128; 55.25 rounds down to 55.

  • Enter your decimal value in a decimal-to-hexadecimal converter, like http://www.binaryhexconverter.com/decimal-to-hex-converter, and convert your values.

@lukepighetti
lukepighetti / Makefile
Last active May 31, 2021 17:29
Basic Flutter Makefile
VERSION = 1.0.0
BUILD = 8
CHANGELOG = Added item counts and a celebration when a list is completed.
.PHONY: clean test build distribute
clean:
flutter clean
flutter pub get
pod repo update
import SwiftUI
private struct OnFirstAppear: ViewModifier {
let perform: () -> Void
@State private var firstTime = true
func body(content: Content) -> some View {
content.onAppear {
if firstTime {
@lukepighetti
lukepighetti / text_editing_controller_builder.dart
Last active September 27, 2021 20:32
Wrap any TextField with TextEditingControllerBuilder to make it declarative
import 'package:flutter/widgets.dart';
class TextEditingControllerBuilder extends StatefulWidget {
/// Exposes a [TextEditingController] to the child, which allows
/// us to convert any [TextField] into a declarative version.
///
/// Typically used for wiring up many state fields to form inputs
/// and making sure everything stays in sync.
///
/// If [text] is updated, the consuming [TextField] will also be updated.
@interference-security
interference-security / writable-avd.md
Last active March 18, 2025 03:19
How to make AVD system and file-system writable?