Skip to main content

mapgl_2gis_web 0.0.4 copy "mapgl_2gis_web: ^0.0.4" to clipboard
mapgl_2gis_web: ^0.0.4 copied to clipboard

Platformweb

A high-performance Flutter Web wrapper for 2GIS MapGL JS API. Fully supports Dart 3 JS Interop and WASM.

example/lib/main.dart

//example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:mapgl_2gis_web/mapgl_2gis_web.dart';

import 'screens/clasterer_screen.dart';
import 'screens/minimal_screen.dart';
import 'splash.dart';

void main() {
  mapglDebugLoggingEnabled = true;
  WidgetsFlutterBinding.ensureInitialized();

  warmUpMapgl().catchError((Object e, StackTrace st) {
    debugPrint('[MapGL] warmUp failed (non-fatal, widget will retry): $e');
  });

  hideSplash();

  runApp(const ExampleApp());
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MapGL 2GIS — Demos',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple), useMaterial3: true),
      home: const _DemoShell(),
    );
  }
}

/// Two-tab shell for switching between the minimal demo and the clusterer
/// demo. As more demos are added, this is the natural place to grow into a
/// `NavigationRail` or a list-based home page.
class _DemoShell extends StatefulWidget {
  const _DemoShell();

  @override
  State<_DemoShell> createState() => _DemoShellState();
}

class _DemoShellState extends State<_DemoShell> {
  int _index = 0;

  static const _screens = [MinimalScreen(), ClastererScreen()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(index: _index, children: _screens),
      bottomNavigationBar: NavigationBar(
        selectedIndex: _index,
        onDestinationSelected: (i) => setState(() => _index = i),
        destinations: const [
          NavigationDestination(icon: Icon(Icons.map_outlined), selectedIcon: Icon(Icons.map), label: 'Minimal'),
          NavigationDestination(
            icon: Icon(Icons.scatter_plot_outlined),
            selectedIcon: Icon(Icons.scatter_plot),
            label: 'Clusters',
          ),
        ],
      ),
    );
  }
}
0
likes
130
points
59
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A high-performance Flutter Web wrapper for 2GIS MapGL JS API. Fully supports Dart 3 JS Interop and WASM.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, web

More

Packages that depend on mapgl_2gis_web