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);
@josh-burton
josh-burton / json
Created November 22, 2021 21:24
allOf dart-dio-next bug
{
"openapi": "3.0.0",
"info": {
"title": "TestApi",
"version": "1.0"
},
"paths": {
"/users/{userId}": {
"parameters": [
{
@josh-burton
josh-burton / main.dart
Created April 7, 2021 20:19
split view overflow box
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
allProjects {
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += [
"-Adagger.formatGeneratedSource=disabled",
"-Adagger.gradle.incremental=true"
]
}
afterEvaluate {
@josh-burton
josh-burton / installflutter.sh
Last active March 3, 2018 20:28
install flutter on bitrise
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
cd ..
git clone -b dev https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
envman add --key PATH --value $PATH
@josh-burton
josh-burton / SharedPreferencesObservable.kt
Created February 1, 2018 18:50
A kotlin extension to allow shared preference values to be observed
inline fun <reified T> SharedPreferences.observe(keyToObserve: String, defaultValue: T): Observable<T> {
return Observable.create<T> { emitter ->
val listener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
if (key == keyToObserve) {
val value = sharedPreferences.all[key]
if (value is T) {
emitter.onNext(value)
} else {
Timber.w("SharedPreferences", "Warning: observed preference type does not match")
@josh-burton
josh-burton / mapme-additems.kt
Created September 7, 2017 02:39
MapMe - add items
// add new data and tell the adapter about it
items.addAll(myData)
adapter.notifyDataSetChanged()
// or with DiffUtil
val diff = DiffUtil.calculateDiff(myDiffCallback)
diff.dispatchUpdatesTo(adapter)
@josh-burton
josh-burton / mapme-setup.kt
Created September 7, 2017 02:36
MapMe setup
val adapter: MapMeAdapter = GoogleMapMeAdapter(context, items)
adapter.setOnAnnotationClickListener(this)
mapView.getMapAsync { googleMap ->
//Attach the adapter to the map view once it's initialized
adapter.attach(mapView, googleMap)
}
@josh-burton
josh-burton / mapme.kt
Created September 7, 2017 02:32
MapMe Kotlin Adapter
class MapsAdapter(context: Context, private val markers: List<MarkerData>) : GoogleMapMeAdapter(context) {
fun onCreateAnnotation(factory: AnnotationFactory, position: Int, annotationType: Int): MapAnnotation {
val item = this.markers[position]
return factory.createMarker(item.getLatLng(), null, item.getTitle())
}
fun onBindAnnotation(annotation: MapAnnotation, position: Int, payload: Any) {
if (annotation is MarkerAnnotation) {
val item = this.markers[position]
@josh-burton
josh-burton / androidmanifest.xml
Created May 3, 2017 02:07
Prevent TouchWiz from surrounding your app icon in a frame
<!-- Prevents TouchWiz from surrounding your app icon in a frame -->
<!-- Add to your manifest inside the application tag -->
<meta-data
android:name="com.samsung.android.icon_container.has_icon_container"
android:value="true"/>