Skip to content

Instantly share code, notes, and snippets.

View GroovinChip's full-sized avatar
🍪

Reuben Turner GroovinChip

🍪
View GitHub Profile
@lukepighetti
lukepighetti / rounded_rectangle.dart
Created May 4, 2023 20:07
Boring RoundedRectangle with platform aware superellipse corners
import 'dart:io';
import 'package:figma_squircle/figma_squircle.dart';
import 'package:flutter/widgets.dart';
class RoundedRectangle extends StatelessWidget {
const RoundedRectangle({
super.key,
this.radius = 10,
this.height,
for f in $(find ./ -name '*.dart')
do
(echo "// @dart=2.9" && cat $f) > filename1 && mv filename1 $f
done
@lukepighetti
lukepighetti / example.dart
Last active March 27, 2021 00:54
Simple route generator that exposes arguments and query params to route builders
main() {
BuildContext context;
final router = NavigationService(context);
return MaterialApp(
onGenerateRoute: (settings) => router.handleGenerateRoute(
settings,
routes: {
'/': (params, context) => HomeView(),
@lukepighetti
lukepighetti / database.dart
Last active March 25, 2021 18:43
A dead simple JSON based key/value store that is unbelievably useful for scripts and tools
import 'dart:convert';
import 'dart:io';
class Database {
/// A simple JSON file database
Database(String path) : file = File(path);
final File file;
var _store = <String, dynamic>{};
@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(),
));
}
@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 / 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:
@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:
@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),
},
@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)"