Skip to content

Instantly share code, notes, and snippets.

View buntagonalprism's full-sized avatar

Alex Bunting buntagonalprism

View GitHub Profile
@buntagonalprism
buntagonalprism / Dart Class.dart
Last active April 2, 2023 12:22
Flutter and Dart collection of file templates for Android Studio development
#set( $nameparts = $NAME.split("_"))
#set( $namepart = '')
#set( $classname = '')
#foreach( $namepart in $nameparts )
#set( $classname = $classname + $namepart.substring(0, 1).toUpperCase() + $namepart.substring(1))
#end
class $classname {
// TODO: add class properties and methods
@buntagonalprism
buntagonalprism / sliver_grid_fixed_height_delegate.dart
Created July 21, 2022 08:36
Sliver grid delegate for items with fixed height and minimum width
import 'dart:math' as math;
import 'package:flutter/rendering.dart';
class SliverGridDelegateWithFixedMainAxisExtent extends SliverGridDelegate {
/// Creates a delegate that makes grid layouts with tiles that have a fixed
/// main axis extent and a minimum cross axis extent. This delegate will
/// attempt to fit as many items as possible in the cross axis while respecting
/// the minimum width.
///
@buntagonalprism
buntagonalprism / adb_record_gif.ps1
Created November 11, 2021 01:21
Use Android Debug Bridge (ADB) to record a gif from a connected physical device or emulator
adb devices
$screenSize = adb shell wm size
$sizeMatches = [regex]::match($screenSize, '(\d+)x(\d+)')
$screenHeight = $sizeMatches.Groups[2].Value
$screenWidth = $sizeMatches.Groups[1].Value
$recordHeight = $screenHeight / 2
$recordWidth = $screenWidth / 2
$recordingSize = "${recordWidth}x${recordHeight}"
$recordingName = "recording_" + [DateTimeOffset]::Now.ToUnixTimeSeconds() + ".mp4"
$recordingPath = "/sdcard/${recordingName}"
// my_feature.dart
class MyFeatureLauncher {
final _factory = di<MyFeatureBlocFactory>();
void show(BuildContext context) {
Navigator.of(context).push(MaterialPageRoute(
settings: RouteSettings(name: '/my-feature'),
builder: (context) => BlocProvider(
block: _factory.init(diCon<Strings>(context)),
@buntagonalprism
buntagonalprism / Individual Dart Class.dart
Last active June 7, 2018 03:21
Individual Dart Class template file for inclusion in Medium article
#set( $nameparts = $NAME.split("_"))
#set( $namepart = '')
#set( $classname = '')
#foreach( $namepart in $nameparts )
#set( $classname = $classname + $namepart.substring(0, 1).toUpperCase() + $namepart.substring(1))
#end
class $classname {
// TODO: add class properties and methods
@buntagonalprism
buntagonalprism / Individual Dart JSON Model.dart
Last active June 7, 2018 03:20
Individual Dart JSON Model class template file for inclusion in Medium article
#set( $nameparts = $NAME.split("_"))
#set( $namepart = '')
#set( $classname = '')
#foreach( $namepart in $nameparts )
#set( $classname = $classname + $namepart.substring(0, 1).toUpperCase() + $namepart.substring(1))
#end
import 'package:json_annotation/json_annotation.dart';
part #[[']]#$NAME#[[.g.dart']]#;
@buntagonalprism
buntagonalprism / Individual Flutter Stateless Widget.dart
Created June 7, 2018 03:19
Individual Flutter Stateless Widget template file for inclusion in Medium article
#set( $nameparts = $NAME.split("_"))
#set( $namepart = '')
#set( $classname = '')
#foreach( $namepart in $nameparts )
#set( $classname = $classname + $namepart.substring(0, 1).toUpperCase() + $namepart.substring(1))
#end
import 'package:flutter/material.dart';
class $classname extends StatelessWidget {
@buntagonalprism
buntagonalprism / Individual Flutter Stateful Widget.dart
Created June 7, 2018 03:19
Individual Flutter Stateful Widget template file for inclusion in Medium article
#set( $nameparts = $NAME.split("_"))
#set( $namepart = '')
#set( $classname = '')
#foreach( $namepart in $nameparts )
#set( $classname = $classname + $namepart.substring(0, 1).toUpperCase() + $namepart.substring(1))
#end
import 'package:flutter/material.dart';
class $classname extends StatefulWidget {