static_map 0.1.1
static_map: ^0.1.1 copied to clipboard
Quickly generate static maps for your app.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:static_map/static_map.dart';
import 'dart:math' as math;
void main() {
StaticMap.initialize(apiKey: 'your_api_key_here');
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Journey Static Map Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Journey Static Map Example'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
int cappedDevicePixelRatio =
math.min(3, MediaQuery.of(context).devicePixelRatio).ceil();
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: LayoutBuilder(builder: (context, constraints) {
return Center(
child: StaticMapImage(
options: StaticMapOptions(
center: LatLng(37.7749, -122.4194),
zoom: 12,
width: 300,
height: 300,
scale: cappedDevicePixelRatio,
),
),
);
}),
);
}
}