This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:unittest/unittest.dart'; | |
import '../bin/singleton_pattern.dart'; | |
void main(){ | |
test("'new' shouldn't be able to create a new instance of SingleObject", (){ | |
expect(() => (new SingleObject()), throwsA(new isInstanceOf<NoSuchMethodError>())); | |
}); | |
test("Should return and instance of SingleObject", (){ | |
expect(() => SingleObject.getInstance(), returnsNormally); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SingleObject{ | |
static final SingleObject _instance = new SingleObject._internal(); | |
static SingleObject getInstance(){ | |
return _instance; | |
} | |
void showMessage(){ | |
print("Hello World!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
//Get the only object available | |
SingleObject object = SingleObject.getInstance(); | |
// this would cause a compilation error | |
//SingleObject singleObject = new SingleObject(); | |
//show the message | |
object.showMessage(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Gists{ | |
// instance variable for user | |
String user; | |
getGistsForUser(String user){ | |
this.user = user; | |
var url = "https://api.github.com/users/${this.user}/gists"; | |
http.get(url) | |
.then(_processResults) | |
.catchError(_handleError); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:http/http.dart' as http; | |
import 'dart:convert'; | |
import 'dart:io'; | |
class Gists{ | |
// instance variable for user | |
String user; | |
getGistsForUser(String user){ | |
this.user = user; | |
var url = "https://api.github.com/users/${this.user}/gists"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:http/http.dart' as http; | |
import 'dart:convert'; | |
import 'dart:io'; | |
import 'dart:async'; | |
class Gists{ | |
// instance variable for user | |
String user; | |
Future getGistsForUser(String user){ | |
this.user = user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:http/http.dart' as http; | |
Future makeRequest(String url) => http.get(url) | |
.then((res) => res.body); | |
void main() { | |
makeRequest('http://www.google.com') | |
.then((value) => print(value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
import 'dart:async'; | |
Future createFile(String fileName, String text){ | |
return new File(fileName).create() | |
.then((File file){ | |
file.writeAsStringSync(text); | |
return 'the file has been created with "$text" as its content'; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../components/polymer/polymer.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
#google_map_search { | |
left: 450px; | |
top: 230px; | |
position: absolute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function heartbeat(){ | |
if(document.querySelector('.demo--completed') != null){ | |
eventFire(document.querySelector('.demo__restart'),'click'); | |
} | |
setTimeout(heartbeat,1000); | |
} | |
function eventFire(el, etype){ | |
if (el.fireEvent) { |