city_picker_from_map 0.0.1 copy "city_picker_from_map: ^0.0.1" to clipboard
city_picker_from_map: ^0.0.1 copied to clipboard

A flutter package for select a city from svg map.

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      home: HomeView(),
      theme: ThemeData.dark(),
    );
  }
}

class HomeView extends StatefulWidget {
  @override
  _HomeViewState createState() => _HomeViewState();
}

class _HomeViewState extends State<HomeView> {
  City? selectedCity;
  final GlobalKey<CityPickerMapState> _mapKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Selected City: ${selectedCity?.title ?? '(?)'}'),
        actions: [
          IconButton(
              icon: Icon(Icons.delete, color: Colors.red),
              onPressed: () {
                _mapKey.currentState?.clearSelect();
                setState(() {
                  selectedCity = null;
                });
              })
        ],
      ),
      body: Center(
        child: InteractiveViewer(
          scaleEnabled: true,
          panEnabled: true,
          constrained: true,
          child: CityPickerMap(
            key: _mapKey,
            width: double.infinity,
            height: double.infinity,
            map: Maps.TURKEY,
            onChanged: (city) {
              setState(() {
                selectedCity = city;
              });
            },
            actAsToggle: true,
            dotColor: Colors.white,
            selectedColor: Colors.lightBlueAccent,
            strokeColor: Colors.white24,
          ),
        ),
      ),
    );
  }
}
43
likes
120
pub points
60%
popularity

Publisher

unverified uploader

A flutter package for select a city from svg map.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, svg_path_parser

More

Packages that depend on city_picker_from_map