Skip to content

Instantly share code, notes, and snippets.

@BoHellgren
BoHellgren / main.dart
Last active April 17, 2023 02:05
Game main.dart final version
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flame/components/component.dart';
import 'package:flame/sprite.dart';
import 'package:flame/flame.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:firebase_admob/firebase_admob.dart';
// Create the following file with this command: flutter pub run flappy_translator
import 'i18n.dart';
@BoHellgren
BoHellgren / MyGame.dart
Last active April 21, 2020 14:34
Game MyGame class
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
import 'dart:math';
class MyGame extends BaseGame {
static int kills;
static int target;
static final Paint paint = Paint();
static Rect progressIndicatorRect;
static double progressIndicatorLength;
Rect bgRect;
@BoHellgren
BoHellgren / gameclasses.dart
Last active September 24, 2020 17:12
Game final gameclasses.dart
import 'package:flame/position.dart';
import 'package:flutter/material.dart';
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
import 'dart:math';
import 'package:flame/components/component.dart';
import 'package:flame/components/mixins/tapable.dart';
import 'package:flame/sprite.dart';
import 'package:flame/text_config.dart';
import 'i18n.dart';
@JS('navigator.geolocation') // navigator.geolocation namespace
library jslocation; // library name can be whatever you want
import "package:js/js.dart";
// locjs.getCurrentPosition(allowInterop((pos) => success(pos))
@JS('getCurrentPosition') // Accessing method getCurrentPosition from Geolocation API
external void getCurrentPosition(Function success(GeolocationPosition pos), Function error(var err), options);
@JS('watchPosition') // Accessing method watchPosition from Geolocation API
List<LatLng> decodeEncodedPolyline(String encoded) {
List<LatLng> poly = [];
int index = 0, len = encoded.length;
int lat = 0, lng = 0;
BigInt Big0 = BigInt.from(0);
BigInt Big0x1f = BigInt.from(0x1f);
BigInt Big0x20 = BigInt.from(0x20);
while (index < len) {
int shift = 0;
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
Future<BitmapDescriptor> createCustomMarkerBitmap(int markerNumber, String imageURL) async {
int markerWidth;
if (kIsWeb) markerWidth= 30; else markerWidth = 100;