Skip to content

Instantly share code, notes, and snippets.

@Sfshaza
Sfshaza / main.dart
Last active June 2, 2023 04:49
Java-to-Dart codelab: Starting point
void main() {
for (int i = 0; i < 5; i++) {
print('hello ${i + 1}');
}
}
@Sfshaza
Sfshaza / main.dart
Last active December 28, 2022 12:11
Java-to-Dart codelab: Basic bicycle example
class Bicycle {
int cadence;
int speed;
int gear;
Bicycle(this.cadence, this.speed, this.gear);
@override
String toString() => 'Bicycle: $speed mph';
}
@Sfshaza
Sfshaza / main.dart
Created February 24, 2018 05:03
Step 6: Flutter Get Started codelab
// Step 6: Navigate to a new route
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@Sfshaza
Sfshaza / main.dart
Last active November 12, 2020 11:59
Step 7-NEW: Getting Started with Flutter codelab
// Final app - the app's primary color is now white.
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@Sfshaza
Sfshaza / index.html
Last active October 2, 2019 01:41
todo_with_delete
<!DOCTYPE html>
<!--
Copyright (c) 2012, the Dart project authors.
Please see the AUTHORS file for details.
All rights reserved. Use of this source code
is governed by a BSD-style license that can be
found in the LICENSE file.
-->
@Sfshaza
Sfshaza / main.dart
Last active April 12, 2019 00:29
Step 1: Flutter "Getting started" codelab
// 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) {
@Sfshaza
Sfshaza / main.dart
Last active April 12, 2019 00:28
Step 2: Flutter Getting Started Codelab
// Add the English words package and generate a word pairing each
// time the app is hot reloaded.
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
@Sfshaza
Sfshaza / main.dart
Last active April 12, 2019 00:28
Step 3 - Flutter's Getting Started Codelab
// Add a stateful widget
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@Sfshaza
Sfshaza / main.dart
Last active April 12, 2019 00:28
Step 4a: Getting Starting with Flutter
// Add the heart icons to the ListView.
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@Sfshaza
Sfshaza / main.dart
Last active August 16, 2018 21:25
Java-to-Dart codelab: Using a try-catch statement
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;