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
// Starting "Hello World" app for the | |
// Getting Started with Flutter codelab. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { |
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
String scream(int length) { | |
return "A${'a' * length}h!"; | |
} | |
main() { | |
var values = [1, 2, 3, 5, 10, 50]; | |
values.skip(1).take(3).map(scream).forEach(print); | |
} |
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
String scream(int length) { | |
return "A${'a' * length}h!"; | |
} | |
main() { | |
var values = [1, 2, 3, 5, 10, 50]; | |
values.map(scream).forEach(print); | |
} |
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
String scream(int length) { | |
return "A${'a' * length}h!"; | |
} | |
main() { | |
var values = [1, 2, 3, 5, 10, 50]; | |
for (var length in values) { | |
print(scream(length)); | |
} | |
} |
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:math'; | |
abstract class Shape { | |
factory Shape(String type) { | |
if (type == "circle") return new Circle(2); | |
if (type == "square") return new Square(2); | |
throw new ArgumentError("Can't create $type."); | |
} | |
num get area; | |
} |
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:math'; | |
abstract class Shape { | |
factory Shape(String type) { | |
if (type == 'circle') return new Circle(2); | |
if (type == 'square') return new Square(2); | |
throw 'Can\'t create $type.'; | |
} | |
num get area; | |
} |
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:math'; | |
abstract class Shape { | |
num get area; | |
} | |
class Circle implements Shape { | |
final num radius; | |
Circle(this.radius); | |
num get area => PI * pow(radius, 2); |
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:math'; | |
abstract class Shape { | |
factory Shape(String type) { | |
if (type == 'circle') return new Circle(2); | |
if (type == 'square') return new Square(2); | |
// To trigger exception, don't implement a check for 'triangle'. | |
throw 'Can\'t create $type.'; | |
} | |
num get area; |
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:math'; | |
abstract class Shape { | |
num get area; | |
} | |
class Circle implements Shape { | |
final num radius; | |
Circle(this.radius); | |
num get area => PI * pow(radius, 2); |
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:math'; | |
class Rectangle { | |
Point origin; | |
int width; | |
int height; | |
Rectangle({this.origin = const Point(0, 0), this.width = 0, this.height = 0}); | |
@override |