如何使用地理位置在颤振中添加图片中的当前位置

时间:2021-07-19 09:34:50

标签: flutter

https://github.com/kardotinambunan12/tinambunan/blob/master/Screenshot%20from%202021-07-08%2017-03-51.png

如果我单击 gps_fixed 图标,则我的位置将显示在文本字段中。

我仍在为模板编写代码。但逻辑部分我不明白。

模板:

 Padding(
          padding: const EdgeInsets.all(14.0),
          child: TextField(
            decoration: InputDecoration(
              hintText: "sampel",

              fillColor: whiteColor,
              // enabled:false,
              prefixIcon: Icon(
                Icons.add_location_outlined,
                color: primaryColor,
              ),
              suffixIcon: IconButton(
                onPressed: () {},
                icon: Icon(Icons.gps_fixed),
                color: primaryColor,
              ),
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.circular(25.0),
                borderSide: BorderSide(color: primaryColor),
              ),
            ),
          ),
        ),
        SizedBox(
          height: 2,
        ),
        Padding(
          padding: const EdgeInsets.all(25.0),
          child: CustomRaiseButton(
            "Clock In",
            color: primaryColor,
            textColor: whiteColor,
          ),
        )

1 个答案:

答案 0 :(得分:0)

您可以使用 Geocoding API 从其坐标中获取位置名称,该插件由名为 geocoding 的插件很好地实现

就这么简单

import 'package:geocoding/geocoding.dart';

List<Placemark> placemarks = await placemarkFromCoordinates(52.2165157, 6.9437819);