Skip to content

Instantly share code, notes, and snippets.

View moho12n's full-sized avatar
💭
Building something cool :D !

Mohamed Douzane moho12n

💭
Building something cool :D !
  • Paris
View GitHub Profile
onPageChanged: (int index) {
setState(() => _index = index);
indexMarker = Tools.markersList[index].id;
if (Tools.markersList[index].latitude != null &&
Tools.markersList[index].longitude != null) {
newPosition = LatLng(
double.tryParse(
Tools.markersList[index].latitude),
double.tryParse(
Tools.markersList[index].longitude));
Positioned.fill(
child: ValueListenableBuilder(
valueListenable: valueNotifier,
builder: (context, value, child) {
return GoogleMap(
zoomControlsEnabled: false,
markers: markers,
myLocationEnabled: true,
myLocationButtonEnabled: false,
onMapCreated: _onMapCreated,
int _index = 0;
int indexMarker;
ValueNotifier valueNotifier = ValueNotifier(indexMarker);
//******* getMarkers */
Future<Uint8List> getBytesFromAsset(String path, int width) async {
ByteData data = await rootBundle.load(path);
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(),
targetWidth: width);
ui.FrameInfo fi = await codec.getNextFrame();
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))
.buffer
.asUint8List();
}
@moho12n
moho12n / mapScreen.dart
Created June 14, 2020 20:43
import packages
import 'dart:typed_data';
import 'dart:async';
import "package:flutter/material.dart";
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter/services.dart';
import 'dart:ui' as ui;
import 'package:flutter/widgets.dart';
import '../tools/tools.dart';
import '../models/markerModel.dart';
class Tools {
static List<MarkersModel> markersList = List();
}
class MarkersModel {
int id;
String name;
String description;
String latitude;
String longitude;
String image;
MarkersModel(
this.id,
this.name,
@moho12n
moho12n / mapScreen.dart
Last active June 14, 2020 20:27
PageView.Builder
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(bottom: 78.0),
child: SizedBox(
height: 116, // card height
child: PageView.builder(
itemCount: 3, // how many items do we have
controller: PageController(viewportFraction: 0.9),
onPageChanged: (int index) {
@moho12n
moho12n / mapScreen.dart
Last active June 14, 2020 20:23
MediumArticle
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
//Global Variables
const LatLng _center = const LatLng(36.737232, 3.086472);
Set<Marker> markers = {};
class MainMapScreen extends StatefulWidget {
@moho12n
moho12n / AndroidManifest.xml
Created June 14, 2020 19:30
MediumArticle
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR ANDROID API KEY HERE"/>