Skip to content

Instantly share code, notes, and snippets.

Amir Hardon amirh

View GitHub Profile
View state_test.dart
test('move right', () {
BoardState state = new BoardState([
[0, 2, 0, 0],
[0, 2, 0, 2],
[8, 0, 4, 4],
[2, 2, 0, 2],
]);
expect(state.moveRight().tiles, [
[0, 0, 0, 2],
View 2048_gesture_detector.dart
return new GestureDetector(
behavior: HitTestBehavior.opaque,
onHorizontalDragEnd: (DragEndDetails d) {
if (d.primaryVelocity > 0) {
GameRedux.dispatch(context, moveRight());
} else {
GameRedux.dispatch(context, moveLeft());
}
},
//...
View generate_pushid.dart
import 'dart:math' as math;
const String _kPushChars = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
typedef String StringCallback();
StringCallback generatePushId = () {
int lastPushTime = 0;
final List<int> randomSuffix = new List<int>(12);
final math.Random random = new math.Random.secure();
You can’t perform that action at this time.