Skip to content

Instantly share code, notes, and snippets.

@Zverik
Created May 28, 2024 11:25
Show Gist options
  • Save Zverik/d056509e22eeecffdefb3a42a587325f to your computer and use it in GitHub Desktop.
Save Zverik/d056509e22eeecffdefb3a42a587325f to your computer and use it in GitHub Desktop.
Assertion for the mapController
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart' show LatLng;
void main() {
runApp(const MaterialApp(
title: 'Flutter Demo',
home: PoiEditorPage(),
));
}
class PoiEditorPage extends StatefulWidget {
const PoiEditorPage({super.key});
@override
State createState() => _PoiEditorPageState();
}
class _PoiEditorPageState extends State<PoiEditorPage> {
final _mapController = MapController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Editor')),
body: ListView(
children: [
SizedBox(
height: 100.0,
child: FlutterMap(
mapController: _mapController,
options: const MapOptions(
initialCenter: LatLng(50, 30),
initialZoom: 17,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
),
],
),
),
for (int i = 1; i < 50; i++)
Padding(
padding: const EdgeInsets.all(30.0),
child: Center(
child: Text('Line $i', style: const TextStyle(fontSize: 20))),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment