sharemap_maplib_flutter 1.0.1
sharemap_maplib_flutter: ^1.0.1 copied to clipboard
A MapLibre-based map widget for Flutter integrating ShareMap APIs, supporting dynamic POI layer toggling, HMAC-signed requests, and custom style loading.
example/lib/main.dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'background_location_demo.dart';
void main() {
runApp(const BackgroundLocationQaApp());
}
class BackgroundLocationQaApp extends StatelessWidget {
const BackgroundLocationQaApp({super.key});
@override
Widget build(BuildContext context) {
const background = Color(0xFF07111F);
const surface = Color(0xFF101C2E);
const outline = Color(0xFF26364D);
const primary = Color(0xFF38BDF8);
const success = Color(0xFF34D399);
return MaterialApp(
title: 'Kiểm tra vị trí nền',
debugShowCheckedModeBanner: false,
theme: ThemeData(
brightness: Brightness.dark,
scaffoldBackgroundColor: background,
cardColor: surface,
colorScheme: const ColorScheme.dark(
primary: primary,
secondary: success,
surface: surface,
outline: outline,
error: Color(0xFFFB7185),
),
inputDecorationTheme: InputDecorationTheme(
filled: true,
fillColor: const Color(0xFF0B1627),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: outline),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: outline),
),
),
cardTheme: CardThemeData(
elevation: 0,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: const BorderSide(color: outline),
),
),
filledButtonTheme: FilledButtonThemeData(
style: FilledButton.styleFrom(
minimumSize: const Size(0, 48),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
minimumSize: const Size(0, 48),
side: const BorderSide(color: outline),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
home: const BackgroundLocationQaHome(),
);
}
}
class BackgroundLocationQaHome extends StatelessWidget {
const BackgroundLocationQaHome({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
titleSpacing: 20,
title: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Kiểm tra vị trí nền',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700),
),
Text(
'ShareMapLibre · Dữ liệu tự lưu trên thiết bị',
style: TextStyle(
color: Color(0xFF94A3B8),
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
],
),
),
body: supportsBackgroundLocationExample
? const BackgroundLocationDemo()
: const _UnsupportedPlatformView(),
);
}
}
bool get supportsBackgroundLocationExample =>
!kIsWeb &&
(defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS);
class _UnsupportedPlatformView extends StatelessWidget {
const _UnsupportedPlatformView();
@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Card(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.phone_iphone_rounded,
size: 44,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 16),
const Text(
'Cần thiết bị Android hoặc iPhone',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
),
const SizedBox(height: 8),
const Text(
'Ứng dụng QA này chỉ kiểm tra Background Location native. '
'Hãy build và chạy trên Android hoặc iOS.',
textAlign: TextAlign.center,
style: TextStyle(color: Color(0xFF94A3B8), height: 1.5),
),
],
),
),
),
),
),
);
}
}