Skip to content

Instantly share code, notes, and snippets.

View ThinkDigitalSoftware's full-sized avatar
💭
An app a day keeps the doctor away

Jonathan White ThinkDigitalSoftware

💭
An app a day keeps the doctor away
  • ThinkDigitalSoftware
  • California, United States of America
View GitHub Profile
@ThinkDigitalSoftware
ThinkDigitalSoftware / main.dart
Created February 2, 2019 19:59
reduce example with custom items
main(){
List<SalesItem> salesList = List.generate(10, (int i) => SalesItem(i));
print("salesList = $salesList");
// the map function takes one thing and converts it to another. You can use it to take an object,
// perform an operation and return the modified object. The function below unwraps the price so that
// I have a list of ints only. (Since you technically can't "add" [SalesItem]s.
List<int> listOfOnlyPrices =
salesList.map<int>((SalesItem item) => item.price).toList();
@ThinkDigitalSoftware
ThinkDigitalSoftware / colored_tab_bar.dart
Last active May 10, 2019 18:35
A custom TabBar where you can control the color behind the Tabs
class ColoredTabBar extends Container implements PreferredSizeWidget {
ColoredTabBar({@required this.color, this.tabBar, this.header});
final Color color;
final TabBar tabBar;
final Widget header;
@override
Size get preferredSize =>
tabBar?.preferredSize ?? Size(double.infinity, 48.0);
@ThinkDigitalSoftware
ThinkDigitalSoftware / main.dart
Created August 2, 2019 01:53
Switch statement using runtimeType in Dart
main(){
var a = B();
switch(a.runtimeType){
case A:{
print ("A");
break;
}
case B:{
print ("B");
break;
@ThinkDigitalSoftware
ThinkDigitalSoftware / pre_commit.dart
Last active August 23, 2019 22:09
A dart pre-commit script that can be used to make sure you update your build version in the pubspec.yaml before committing. This can be installed using hanzo. https://pub.dev/packages/hanzo. Note: This must be run from the terminal. If run from the IDE, it will always fail.
import 'dart:convert';
import 'dart:io';
import 'package:meta/meta.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:pubspec/pubspec.dart';
import 'functions.dart';
main(List<String> arguments) async {
@ThinkDigitalSoftware
ThinkDigitalSoftware / main.dart
Created October 17, 2019 00:41
multiple maps example
void main() async {
print(people);
print("Changing color to light Blue");
colors[1] = 'Light Blue';
print(people);
}
class Person{
String name;
int colorIndex;

Language: English | 中文简体

dio #

build status Pub support

A powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout etc.

Get started #

@ThinkDigitalSoftware
ThinkDigitalSoftware / main.dart
Created February 22, 2020 22:39
Invalid analyzer conversion
void main() {
Function func;
func = () {
func2();
};
print(func());
func = () => func2();
@ThinkDigitalSoftware
ThinkDigitalSoftware / main.dart
Created March 11, 2020 00:08
AnimatedList example
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@ThinkDigitalSoftware
ThinkDigitalSoftware / bloc_globals.dart
Last active March 11, 2020 19:44
Adds a simple Bloc delegate that prints events and their calling function.
// don't forget to add `BlocSupervisor.delegate = SimpleBlocDelegate();` to the beginning of your main.dart file.
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class SimpleBlocDelegate extends BlocDelegate {
SimpleBlocDelegate() {
debugPrint(
'[INFO] Initializing SimpleBlocDelegate. Logging all Bloc events to the console');
@ThinkDigitalSoftware
ThinkDigitalSoftware / conversions.md
Created March 12, 2020 19:27
Flutter 1.13.8 to 1.14+ conversions

The names of the TextTheme properties match this table from the /// Material Design spec /// with two exceptions: the styles called H1-H6 in the spec are /// headline1-headline6 in the API, and body1,body2 are called /// bodyText1 and bodyText2.

NAME SIZE WEIGHT SPACING 2018 NAME /// display4 112.0 thin 0.0 headline1 /// display3 56.0 normal 0.0 headline2 /// display2 45.0 normal 0.0 headline3