Skip to content

Instantly share code, notes, and snippets.

View GroovinChip's full-sized avatar
🍪

Reuben Turner GroovinChip

🍪
View GitHub Profile
@GroovinChip
GroovinChip / gist:2e63a0f7b150a49082174e7f1a18dcd5
Last active September 20, 2019 14:01
Codemagic Android release build help
1. Use Gradle 4.10.2 (DO NOT use 5.x)
2. Use 'com.android.tools.build:gradle:3.3.0' in your project-level build.gradle
3. Add this to the very bottom of your app-level build.gradle:
gradle.taskGraph.whenReady { taskGraph ->
def tasks = taskGraph.getAllTasks()
def buildTasks = tasks.find { it.name.startsWith('build') && it.getGroup() == 'build' }
if (buildTasks) {
tasks.findAll {it.name.startsWith('test')}.each { task ->
task.enabled = false
@GroovinChip
GroovinChip / main.dart
Created March 6, 2020 19:54
Dynamic AppBar content based on BottomNavigationBar page index
/// Example for how to dynamically change the appearance of an AppBar based on BottomNavigationBar page index.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@GroovinChip
GroovinChip / README.md
Last active March 28, 2021 02:39
My "Vintage bloc" usage style

My use of the classic (or "vintage") BLoC pattern (not to be confused with Felix Angelov's great bloc library) has evolved over the years. I do no use dedicated sinks for input and dedicated streams for output. Rather, I directly use rxdart's excellent BehaviorSubject directly. BehaviorSubject implements ValueStream, which itself implements Stream, so I found that I could reduce boilerplate a lot by doing this. Values can be directly added to, and read from, a BehaviorSubject. I then use provider to pass my services (I don't really think of them as "bloc"s any more) through my app. This gist provides a real example of how I currently use this pattern.

  • prefs_service.dart is where the service is defined.
  • main.dart shows how to initialize the service.
  • app.dart shows how I use MultiProvider to pass down my service. I always use MultiProvider rather than one single provider to allow for more services. I listen to the BehaviorSubject in my service to set the ThemeMode of my `Ma
@GroovinChip
GroovinChip / act_alias.md
Created July 7, 2022 21:03
act alias for m1 chips with GH token & resusing containers

act is a tool for running GitHub actions locally. Commands can get very unwieldy so I've created an alias in my .zshrc file that makes things easier:

alias actm="act -s GITHUB_TOKEN=YOUR_TOKEN_HERE --container-architecture linux/amd64 -r"

Breakdown:

  • Since some actions require the GITHUB_TOKEN that is included in every repo, it is added here. Replace YOUR_TOKEN_HERE with a personal access token from GitHub.
  • On computers with Apple's m-series chip, the --container-architecture linux/amd64 flag is required
  • The -r flag allows for containers from jobs to be reused, making for faster jobs.
@GroovinChip
GroovinChip / SystemAccentColorProvider.swift
Last active July 9, 2022 17:37
Attempt at a Swift class that listens to changes to the system accent color. Doesn't seem to work at the moment.
//
// SystemAccentColorProvider.swift
// macos_ui
//
// Created by Reuben Turner on 7/9/22.
//
import FlutterMacOS
import AppKit
@GroovinChip
GroovinChip / apps.md
Last active February 15, 2023 15:49
Great macOS apps
@GroovinChip
GroovinChip / setup_tasks.md
Last active February 15, 2023 22:14
Setup tasks for a Flutter environment on a new macOS m1 machine
@GroovinChip
GroovinChip / commands.md
Created October 17, 2022 16:58
Bash commands for listing & totalling all generated Dart files

Get counts of generated files

$ find . -type f -name "*.FILE_TYPE.dart" -exec printf x \; | wc -c

Where FILE_TYPE is the generated file type, such as g or freezed.

Ignoring test directories

$ find . -type f -name "*.FILE_TYPE.dart" -not -path "*/test/*" -exec printf x \; | wc -c
@GroovinChip
GroovinChip / thumb_colors.md
Created January 27, 2023 10:45
macOS scrollbar thumb color values
Mode Mouse hover Hex value
Light #C2C2C2
Light #7D7D7D
Dark #6E6A73
Dark #97959A
@GroovinChip
GroovinChip / get_widget_props_test.md
Created July 11, 2023 14:02
Get properties of a widget in a widget test

Sometimes we need to test that a widget is doing a particular thing based on a provided parameter, or something similar. We can do this by using tester.widget and TypeMatcher's having() function.

Let's say we have a custom app bar that, using package:badges, should show a badge on the leading widget (which shows if there is a drawer) if the int badgeCount passed to it is greater than zero. Simply testing for the existence of the Badge widget isn't correct, because Badge is always being built - we need to test if the badge's showBadge property is false. We'd write our test like so:

import 'package:badges/badges.dart';
import 'package:flutter/material.dart' hide Badge;
import 'package:flutter_test/flutter_test.dart';
import 'package:my_package/src/widgets/custom_app_bar.dart';