Skip to content

Instantly share code, notes, and snippets.

View mingsai's full-sized avatar
🎯
Focusing

Tommie N. Carter, Jr. mingsai

🎯
Focusing
View GitHub Profile
@mingsai
mingsai / gist:32461fc93d176eb3ee9f8e6f7935d94c
Last active August 29, 2021 15:29
Flutter - dismiss keyboard on tap
//wrap the layout widget for the screen with a Gesture detector having this function
GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
@mingsai
mingsai / pass_arguments.dart
Last active August 28, 2021 01:10
Flutter - How to pass an object using the Navigator between two screens
//View #1 Pass any object as an argument in the Navigator as part of a Map:
void _editItem(BuildContext context, int index, Box<ChecklistItem> box) {
ChecklistItem _selectedItem = box.getAt(index) as ChecklistItem;
Navigator.pushNamed(context, ChecklistEditScreen.id,
arguments: {'item': _selectedItem});
}
//View #2 Extract passed flutter arguments without passing them as parameters:
Widget build(BuildContext context) {
@mingsai
mingsai / rebuild_widgets.dart
Created August 27, 2021 18:03
Flutter rebuild all widgets
void _rebuildAllChildren(BuildContext context) {
void rebuild(Element el) {
el.markNeedsBuild();
el.visitChildren(rebuild);
}
(context as Element).visitChildren(rebuild);
}
@mingsai
mingsai / dismissible_widget_sample.dart
Created August 27, 2021 18:02
Dismissable Widget Sample
return Dismissible(
key: Key(index.toString()),
onDismissed: (direction) {
showDialog(
context: context,
barrierDismissible: false,
builder: (_) => AlertDialog(
content: Text(
"Do you want to delete task ${currentItem.title}?",
),
@mingsai
mingsai / MNGStreamReaderWriter.swift
Last active August 2, 2021 16:13
A Stream Reader / Writer that takes two URLs and copies from source to target without exceeding memory limits.
//
// MNGStreamReaderWriter.swift
// ths
//
// Created by Tommie N. Carter, Jr., MBA on 2/14/16.
// Copyright © 2016 MING Technology. All rights reserved.
//
import Foundation
import Darwin.Mach.mach_time
@mingsai
mingsai / trim_string_sample.applescript
Created May 28, 2020 11:54
Applescript: Trim text front and back example
set whichFile to choose file with multiple selections allowed
repeat with aFile in whichFile
tell application "Finder"
set filename to name of aFile
set name of aFile to ((characters 4 thru -1 of filename) as string) --trim first 3
--set name of whichFile to ((characters 1 thru -4 of filename) as string) --trim last 3
end tell
end repeat
@mingsai
mingsai / .gitignore
Last active March 10, 2021 12:23
Flutter projects git ignore
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
@mingsai
mingsai / find_dupes.js
Created February 20, 2021 00:33
Google Sheets - Find Duplicates
// Find Duplicates
// Kurt Kaiser, 2018
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
// Creates an array with data from a chosen column
function readData() {
var column = 2;
var lastRow = sheet.getLastRow();
@mingsai
mingsai / screen_capture_example.dart
Created January 5, 2021 21:22
Flutter screen capture example
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:rtjf/components/home_content.dart';
class HomeScreen extends StatefulWidget {
static const String id = '/home_screen';
@override
_HomeScreenState createState() => _HomeScreenState();
@mingsai
mingsai / flutter_capture_screen.dart
Created January 5, 2021 21:20
Flutter capture screen image
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:image_picker_saver/image_picker_saver.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
void main() => runApp(new MyApp());