Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
55 views3 pages

Scrolling Map - Dart

The document describes a ScrollingMapPage class that contains two scrolling maps - one that consumes all touch events and one that does not consume vertical drags. The maps are displayed in list view cards and show a centered map with markers at a fixed zoom level.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views3 pages

Scrolling Map - Dart

The document describes a ScrollingMapPage class that contains two scrolling maps - one that consumes all touch events and one that does not consume vertical drags. The maps are displayed in list view cards and show a centered map with markers at a fixed zoom level.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

// Copyright 2018 The Chromium Authors. All rights reserved.

// Use of this source code is governed by a BSD-style license that can be


// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

import 'page.dart';

class ScrollingMapPage extends GoogleMapExampleAppPage {


ScrollingMapPage() : super(const Icon(Icons.map), 'Scrolling map');

@override
Widget build(BuildContext context) {
return const ScrollingMapBody();
}
}

class ScrollingMapBody extends StatelessWidget {


const ScrollingMapBody();

final LatLng center = const LatLng(32.080664, 34.9563837);

@override
Widget build(BuildContext context) {
return ListView(
children: <Widget>[
Card(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 30.0),
child: Column(
children: <Widget>[
const Padding(
padding: EdgeInsets.only(bottom: 12.0),
child: Text('This map consumes all touch events.'),
),
Center(
child: SizedBox(
width: 300.0,
height: 300.0,
child: GoogleMap(
initialCameraPosition: CameraPosition(
target: center,
zoom: 11.0,
),
gestureRecognizers:
// TODO(iskakaushik): Remove this when collection lite
rals makes it to stable.
// https://github.com/flutter/flutter/issues/28312
// ignore: prefer_collection_literals
<Factory<OneSequenceGestureRecognizer>>[
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
].toSet(),
),
),
),
],
),
),
),
Card(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 30.0),
child: Column(
children: <Widget>[
const Text('This map doesn\'t consume the vertical drags.'),
const Padding(
padding: EdgeInsets.only(bottom: 12.0),
child:
Text('It still gets other gestures (e.g scale or tap).'),
),
Center(
child: SizedBox(
width: 300.0,
height: 300.0,
child: GoogleMap(
initialCameraPosition: CameraPosition(
target: center,
zoom: 11.0,
),
markers:
// TODO(iskakaushik): Remove this when collection lite
rals makes it to stable.
// https://github.com/flutter/flutter/issues/28312
// ignore: prefer_collection_literals
Set<Marker>.of(
<Marker>[
Marker(
markerId: MarkerId("test_marker_id"),
position: LatLng(
center.latitude,
center.longitude,
),
infoWindow: const InfoWindow(
title: 'An interesting location',
snippet: '*',
),
)
],
),
gestureRecognizers:
// TODO(iskakaushik): Remove this when collection lite
rals makes it to stable.
// https://github.com/flutter/flutter/issues/28312
// ignore: prefer_collection_literals
<Factory<OneSequenceGestureRecognizer>>[
Factory<OneSequenceGestureRecognizer>(
() => ScaleGestureRecognizer(),
),
].toSet(),
),
),
),
],
),
),
),
],
);
}
}

You might also like