Skip to content

Instantly share code, notes, and snippets.

View GroovinChip's full-sized avatar
🍪

Reuben Turner GroovinChip

🍪
View GitHub Profile
@kasperpeulen
kasperpeulen / README.md
Last active October 9, 2024 21:44
How to pretty-print JSON using Dart.
@superhard
superhard / colorComponents.swift
Created November 25, 2015 18:25 — forked from ericdke/colorComponents.swift
Swift: color components (css, hex, rgb) from NSColor
extension NSColor {
func components() -> ((alpha: String, red: String, green: String, blue: String, css: String), (alpha: CGFloat, red: CGFloat, green: CGFloat, blue: CGFloat), (alpha: CGFloat, red: CGFloat, green: CGFloat, blue: CGFloat))? {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
var alpha: CGFloat = 0
if var color = self.colorUsingColorSpaceName(NSCalibratedRGBColorSpace) {
color.getRed(&red, green: &green, blue: &blue, alpha: &alpha)
let nsTuple = (alpha: alpha, red: red, green: green, blue: blue)
@slightfoot
slightfoot / reorder_list.dart
Created March 13, 2019 13:08
Basic Reorderable list from Firestore Documents using only inbuilt Widgets. 13th March 2019
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Colors.indigo,
accentColor: Colors.pinkAccent,
@slightfoot
slightfoot / rubber_range_picker.dart
Last active January 19, 2023 01:09
Rubber Range Picker - Based on https://dribbble.com/shots/6101178-Rubber-Range-Picker-Open-Source by Cuberto - 14th March 2019
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
void main() => runApp(ExampleApp());
class ExampleApp extends StatelessWidget {
@override
@jeroen-meijer
jeroen-meijer / fluttercleanrecursive.sh
Created September 15, 2019 13:00
Flutter Clean Recursive - Clear up space on your hard drive by cleaning your Flutter projects. This script searches for all Flutter projects in this directory and all subdirectories and runs 'flutter clean'. Note: may take a long time for folders with large amounts of projects.
#!/bin/sh
# To run, download the script or copy the code to a '.sh' file (for example 'fluttercleanrecursive.sh') and run like any other script:
# sh ./fluttercleanrecursive.sh
# or
# sudo sh fluttercleanrecursive.sh
echo "Flutter Clean Recursive (by jeroen-meijer on GitHub Gist)"
echo "Looking for projects... (may take a while)"
@lukepighetti
lukepighetti / client.dart
Last active September 7, 2021 20:54
Logging service using extensions for channels with multiple outputs
import 'package:logger/logger.dart';
void main() async {
/// Setup logging service
final remoteUrl = Uri.parse('http://localhost:8080');
final logger = LoggingService(
loggers: {
ConsoleLogger(),
RemoteLogger(baseUrl: remoteUrl),
},
@slightfoot
slightfoot / media_query_extension.dart
Last active July 29, 2021 13:32
Media Query Extension - by Simon Lightfoot
// MIT License
//
// Copyright (c) 2020 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / show_debug_paint.dart
Last active August 4, 2022 19:20
ShowsDebugPaint widget - paint outlines for a single widget and its child subtree - by Simon Lightfoot - 13/05/2020 (Not a fix for Flutter Web debug paint issue.. https://github.com/flutter/flutter/issues/32221 )
// MIT License
//
// Copyright (c) 2020 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@ltOgt
ltOgt / conditional_parent_widget.dart
Created June 29, 2020 14:50
Flutter Widget to conditionally wrap a subtree with a parent without breaking the code tree
import 'package:flutter/widgets.dart';
/// Conditionally wrap a subtree with a parent widget without breaking the code tree.
///
/// [condition]: the condition depending on which the subtree [child] is wrapped with the parent.
/// [child]: The subtree that should always be build.
/// [conditionalBuilder]: builds the parent with the subtree [child].
///
/// ___________
/// Usage:
@slightfoot
slightfoot / defer_init.dart
Last active July 19, 2023 12:51
Defer initialization of your UI based on a background service - by Simon Lightfoot - 29/12/2020 - Null Safe!
import 'dart:math' show Random;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show RendererBinding;
void main() {
runApp(MaterialApp(
home: Home(),
));
}