Skip to content

Instantly share code, notes, and snippets.

View josh-burton's full-sized avatar
👋

Josh Burton josh-burton

👋
View GitHub Profile
@josh-burton
josh-burton / main.dart
Last active August 15, 2022 19:56
Riverpod StateProvider select vs watch
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
void main() {
runApp(
const ProviderScope(child: MyApp()),
);
}
final sourceProvider = StateProvider((ref) => 0);
import * as fs from "fs";
import axios from "axios";
const SPACELOOT_CONTRACT_ADDRESS = "terra13qrc9j00lk3x0rvpptzdmwtckfj64d5g6xnrv9";
const START_ID = 0;
const END_ID = 8000;
const IDS_PER_QUERY = 1000;
type MantleResponse = {
import 'package:firedart/firedart.dart';
import 'package:hive/hive.dart';
/// Stores tokens using a Hive store.
/// Depends on the Hive plugin: https://pub.dev/packages/hive
class HiveStore extends TokenStore {
static const keyToken = "auth_token";
static Future<HiveStore> create() async {
// Make sure you call both:
@divyanshub024
divyanshub024 / wave_anim.dart
Last active November 18, 2020 01:35
Flutter Circular Wave Canvas Animation
import 'dart:math' as math;
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@ajinasokan
ajinasokan / flutter_desktop_macos.md
Last active November 22, 2019 14:38
Run Flutter apps in MacOS with IDE support and hot reloading

This setup is only for MacOS. I don't have a windows/linux machine to test.

Clone FDE repo

cd ~
git clone https://github.com/google/flutter-desktop-embedding

Switch to flutter master

@slightfoot
slightfoot / target_border.dart
Last active September 19, 2021 05:30
Flutter TargetBorder for BoxDecoration
import 'package:flutter/material.dart';
class TargetBorder extends Border {
const TargetBorder({
BorderSide side = const BorderSide(color: Colors.white, width: 2.0),
this.depth = 25.0,
this.strokeCap = StrokeCap.square,
}) : super(top: side, right: side, bottom: side, left: side);
final double depth;
@keyboardsurfer
keyboardsurfer / installFromBundle
Last active August 8, 2020 15:33
Build & extract a set of apk from an aab for a specific device and install the results on it.
#!/bin/sh
# Build & extract a set of apk from an aab for a specific device and install the results on it.
#
# This needs https://github.com/google/bundletool to be available as `bundletool`.
# Also **exactly** one device needs to be connected to adb.
# Usage: installFromBundle bundle.aab
# optional `--extract-apks` to keep the set on your workstation as well.
basename=${1%%.*}
keystore="~/.android/debug.keystore"
@hvisser
hvisser / DemoModeEnabler.kt
Created January 23, 2018 11:44
Enables demo mode on a device for the purpose of taking screenshots
class DemoModeEnabler {
fun enable() {
executeShellCommand("settings put global sysui_demo_allowed 1")
sendCommand("exit")
sendCommand("enter")
sendCommand("notifications", "visible" to "false")
sendCommand("network", "wifi" to "hide")
sendCommand("battery", "level" to "100", "plugged" to "false")
sendCommand("clock", "hhmm" to "1000")
@yanngx
yanngx / FragmentArgumentDelegate.kt
Last active January 19, 2023 09:26
Fragment arguments without hassle !
package be.brol
import android.os.Binder
import android.os.Bundle
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created
@serj-lotutovici
serj-lotutovici / GenericPolymorphicJsonAdapterFactory.java
Last active May 8, 2022 19:45
A Moshi JsonAdapter.Factory that creates Polymorphic JsonAdapter. Requires Moshi 1.4.0. (Tests written in kotlin)
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.JsonDataException;
import com.squareup.moshi.JsonReader;
import com.squareup.moshi.JsonWriter;
import com.squareup.moshi.Moshi;
import com.squareup.moshi.Types;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;