Skip to content

Instantly share code, notes, and snippets.

View miquelbeltran's full-sized avatar

Miguel Beltran miquelbeltran

View GitHub Profile
@miquelbeltran
miquelbeltran / main.dart
Created March 3, 2021 17:02 — 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;
}
@miquelbeltran
miquelbeltran / main.dart
Last active March 3, 2021 16:24 — forked from Sfshaza/main.dart
Java-to-Dart codelab: Basic bicycle example
class Bicycle {
late int cadence;
late int speed;
late int gear;
Bicycle(this.cadence, this.speed, this.gear);
@override
String toString() => 'Bicycle: $speed mph';
}
@miquelbeltran
miquelbeltran / pre-push
Created June 4, 2019 07:18
Flutter pre-push hook that runs analyze and test
#!/bin/sh
# To use add to `.git/hooks/`
# Should be named `pre-push`
# Make executable with `chmod +x`
# stash any unstaged changes
git stash -q --keep-index
# run Flutter analyze + test
flutter analyze
@miquelbeltran
miquelbeltran / templates.dart
Created July 3, 2020 08:44
Dart Live Templates for built_value
/// built_value template
/// variables:
/// CLASS_NAME
abstract class $CLASS_NAME$ implements Built<$CLASS_NAME$, $CLASS_NAME$Builder> {
factory $CLASS_NAME$([void Function($CLASS_NAME$Builder) updates]) = _$$$CLASS_NAME$;
$CLASS_NAME$._();
}
@miquelbeltran
miquelbeltran / color_gradient_grid.dart
Created March 9, 2020 20:25
Generate a color gradient grid in Flutter
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
Use the methods `map`, `any` and `where` to solve the exercise.
Use map to create a String with the user.name and the user.age
@miquelbeltran
miquelbeltran / hint.text
Last active December 18, 2019 08:49
filtering
Use the `where` method to implement the filters.
Use the methods `any` and `every` to compare the user age.
Use the methods `contains` and `startWith` from the `String` class.