Skip to content

Instantly share code, notes, and snippets.

@abhaysood
abhaysood / diagnosticable_properties_3.dart
Created May 28, 2021 12:51
Blog: Enrich the Flutter Inspector with Diagnosticable properties
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(IntProperty('_counter', _counter));
properties.add(DiagnosticsProperty<MyColorScheme>('myColorScheme', _myColorScheme));
_myColorScheme.debugFillProperties(properties);
}
@abhaysood
abhaysood / diagnosticable_properties_2.dart
Last active May 28, 2021 12:53
Blog: Enrich the Flutter Inspector with Diagnosticable properties
class MyColorScheme with Diagnosticable {
final Color textColor;
final Color backgroundColor;
MyColorScheme(this.textColor, this.backgroundColor);
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(ColorProperty('textColor', textColor));
@abhaysood
abhaysood / diagnosticable_properties_1.dart
Created May 28, 2021 12:49
Blog: Enrich the Flutter Inspector with Diagnosticable properties
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(IntProperty('_counter', _counter));
}
@abhaysood
abhaysood / main.dart
Created May 26, 2021 08:25
Flutter Diagnosticable demonstration
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@abhaysood
abhaysood / pre-commit
Created May 18, 2021 19:05
A pre-commit hook which fails a commit if formatting issues are encountered (Flutter)
#!/bin/bash
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
fileList=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(dart)$')
if [ ${#fileList} -lt 1 ]; then
# No changes to dart files continue with git commit.
exit
fi
@abhaysood
abhaysood / Dockerfile
Created May 17, 2021 07:18
Dockerfile to build flutter apps/packages: comes with alpine, FVM, Android SDK, flutter stable, lcov
FROM openjdk:8-alpine
USER root
ARG FVM_VERSION="2.0.4"
# Required to build flutter apps on apline
ARG GLIBC_VERSION="2.28-r0"
ENV LCOV_VERSION="1.15"
@abhaysood
abhaysood / main.dart
Created April 27, 2021 07:21
Drag and drop to delete from list
import 'package:flutter/material.dart';
import 'dart:math';
import 'dart:ui' show lerpDouble;
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
@abhaysood
abhaysood / machine.js
Last active September 26, 2020 05:41
Generated by XState Viz: https://xstate.js.org/viz
const summaryState = {
type: 'parallel',
initial: 'loadOrder',
states: {
loadOrder: {
initial: 'loadingOrder',
states: {
idle: {},
loadingOrder: {
on: {
@abhaysood
abhaysood / SketchSystems.spec
Created September 30, 2018 17:58
Home Screen*
Home Screen*
Empty
query changed -> Searching
Showing Results
query changed -> Searching
Searching
network error -> Network Error
server error -> Server Error
@abhaysood
abhaysood / medium_rider_redesign_blog_example.kt
Created March 18, 2018 20:04
A simple component which is created when user clicks the cancel order button in the app. It is responsible for showing a confirmation dialog and actually cancelling the order by making an API call.
class OrderCancellationComponent(private val context: Context,
private val api: Api,
private val orderNumber: String) {
interface Callbacks {
fun onOrderCancelledSuccessfully()
fun onOrderCancellationFailed()
}
var callbacks: Callbacks? = null // Callbacks for communication with the parent component