createHeader method

Widget createHeader(
  1. dynamic context
)

Implementation

Widget createHeader(context) {
  return AutoScreenTypeLayout(
    child: Row(
      children: <Widget>[
        Expanded(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: OutlinedButton(
              onPressed: () {
                Navigator.of(context)
                    .push<LatLng>(
                      MaterialPageRoute(
                        builder: (context) => const ChooseOnMapRoute(),
                      ),
                    )
                    .asStream()
                    .where((event) => event != null)
                    .map((event) => event!)
                    .flatMap(
                      (latLng) => service
                          .reverseGeocode([latLng.latitude, latLng.longitude])
                          .asStream()
                          .map(
                            (address) => Position(
                              latLng: model.LatLng(
                                  lat: latLng.latitude,
                                  lng: latLng.longitude),
                              formattedAddress: address,
                            ),
                          ),
                    )
                    .doOnError(
                        (p0, p1) => showServerError(context, error: p0))
                    .listen(Navigator.of(context).pop);
              },
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Column(
                  children: <Widget>[
                    const Icon(Icons.place),
                    const SizedBox(
                      height: 5,
                    ),
                    Text(lang.chooseOnMap.toUpperCase())
                  ],
                ),
              ),
            ),
          ),
        ),
        Expanded(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: OutlinedButton(
              onPressed: () async {
                Geolocator.getCurrentPosition(
                        timeLimit: const Duration(seconds: 10))
                    .asStream()
                    .asyncMap((latLng) => service
                        .reverseGeocode([latLng.latitude, latLng.longitude]))
                    .doOnError(
                        (p0, p1) => showServerError(context, error: p0))
                    .listen((text) => Navigator.of(context).pop(text));
              },
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Column(
                  children: <Widget>[
                    const Icon(Icons.gps_fixed),
                    const SizedBox(
                      height: 5,
                    ),
                    Text(lang.currentPosition.toUpperCase())
                  ],
                ),
              ),
            ),
          ),
        ),
      ],
    ),
  );
}