Skip to content

Instantly share code, notes, and snippets.

jebright

Block or report user

Report or block jebright

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jebright
jebright / main.dart
Created Apr 16, 2019
Using an Isolate in Flutter
View main.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'dart:isolate';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
@jebright
jebright / sort-objects
Created Sep 23, 2018
Dart Fundamentals - List - Sort Objects
View sort-objects
class Sale {
int employeeId;
double price;
Sale(this.employeeId, this.price);
}
class Employee {
int id;
List<Sale> sales;
Employee (this.id, this.sales);
@jebright
jebright / sort
Created Sep 23, 2018
Dart Fundamentals - Lists - Sort
View sort
void main() {
List<double> prices = [0.25, 1.00, 3.33, 0.75, 4.25, 5.99];
prices.sort();
log(prices); //prints 0.25, 0.75, 1, 3.33, 4.25, 5.99
List<String> alphabet = ["b", "c", "a"];
alphabet.sort();
log(alphabet); //prints a,b,c
}
@jebright
jebright / where
Created Sep 23, 2018
Dart Fundamentals - Lists - Filtering
View where
void main() {
List<double> prices = [0.25, 1.00, 3.33, 0.75, 4.25, 5.99];
var overOneDollar = prices.where((p) => p > 1.00);
log(overOneDollar); //prints 3.33, 4.25, 5.99
}
void log(var lst) {
lst.forEach((n) => print(n));
}
@jebright
jebright / map
Created Sep 23, 2018
Dart Fundamentals - Lists - Map
View map
class Person
{
String firstName;
String lastName;
Person(this.firstName, this.lastName);
}
void main() {
List<Person> people = new List<Person>();
@jebright
jebright / lists
Last active Sep 23, 2018
Dart Fundamentals - Lists - Creating
View lists
void main() {
//Fix lengthed list
var namesFixed = new List<String>(3);
namesFixed[0] = "Joe";
namesFixed[1] = "Frankie";
namesFixed[2] = "Tom";
//namesFixed[3] = "Kaboom!"; //this would be an error
log(namesFixed) ;
@jebright
jebright / foreach
Last active Sep 23, 2018
Dart Fundamentals - Lists - foreach
View foreach
void main() {
List<String> names = ["Joe", "Frankie", "Tom"];
names.forEach((n) =>
print('Hello Mr. ${n}'));
}
@jebright
jebright / loop
Last active Sep 23, 2018
Dart Fundamentals - Lists -loop
View loop
void main() {
List<String> names = ["Joe", "Frankie", "Tom"];
for (var n in names) {
print('Hello ${n}');
}
}
You can’t perform that action at this time.