Skip to content

Instantly share code, notes, and snippets.

@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 02:35 — forked from Sfshaza/main.dart
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';
}
@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 04:01 — forked from kwalrath/main.dart
Java-to-Dart codelab: Starting Shapes example
import 'dart:math';
abstract class Shape {
num get area;
}
class Circle implements Shape {
final num radius;
Circle(this.radius);
@override
@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 04:07 — forked from kwalrath/main.dart
Java-to-Dart codelab: Using a try-catch statement
import 'dart:math';
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
// To trigger exception, don't implement a check for 'triangle'.
throw 'Can\'t create $type.';
}
num get area;
@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 04:10 — forked from kwalrath/main.dart
Java-to-Dart codelab: Top-level factory function
import 'dart:math';
abstract class Shape {
num get area;
}
class Circle implements Shape {
final num radius;
Circle(this.radius);
@override
@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 04:13 — forked from kwalrath/main.dart
Java-to-Dart codelab: Factory constructor
import 'dart:math';
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;
}
@flutterdevrelgists
flutterdevrelgists / main.dart
Created November 5, 2022 04:19 — forked from kwalrath/main.dart
Java-to-Dart codelab: CircleMock example
import 'dart:math';
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;
}
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:01
Adaptive UI Talk AnimatedBuilder Example
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(const AnimatedBuilderExample());
/// This widget listens for changes in the focus state of the subtree defined by
/// its [child] widget, changing the border and color of the container it is in
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:02
Adaptive UI Talk LayoutBuilder Example
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Flutter code sample for [LayoutBuilder].
import 'package:flutter/material.dart';
void main() => runApp(const LayoutBuilderExample());
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:08
Adaptive UI Talk FocusableActionDetector Example
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
@flutterdevrelgists
flutterdevrelgists / main.dart
Created January 24, 2023 23:09
Adaptive UI Talk: Example of handling light mode and dark mode in Material.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override