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 22, 2020 22:39
Invalid analyzer conversion
void main() {
Function func;
func = () {
func2();
};
print(func());
func = () => func2();

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 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;
@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 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 / 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 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();
void main() async {
 await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(MyApp());
}
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.google.android.exoplayer:exoplayer-hls:2.9.1.
Searched in the following locations:
- file:/Users/thinkdigital/Library/Android/sdk/extras/m2repository/com/google/android/exoplayer/exoplayer-hls/2.9.1/exoplayer-hls-2.9.1.pom
- file:/Users/thinkdigital/Library/Android/sdk/extras/m2repository/com/google/android/exoplayer/exoplayer-hls/2.9.1/exoplayer-hls-2.9.1.jar
- file:/Users/thinkdigital/Library/Android/sdk/extras/google/m2repository/com/google/android/exoplayer/exoplayer-hls/2.9.1/exoplayer-hls-2.9.1.pom
- file:/Users/thinkdigital/Library/Android/sdk/extras/google/m2repository/com/google/android/exoplayer/exoplayer-hls/2.9.1/exoplayer-hls-2.9.1.jar
Card(
color: backgroundColor,
margin: EdgeInsets.symmetric(vertical: 10, horizontal: 5),
child: Padding(
padding: const EdgeInsets.only(
left: 15,
right: 5,
top: 8,
bottom: 8), //symmetric(vertical: 8.0, horizontal: 15),
child: new Row(