location_context 1.0.3+1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 67

location_context

Build Status

Helper functions to share location data using InheritedWidgets

This plugin is also available on pub

Getting Started

For help getting started with Flutter, view our online documentation. You can also visit us at Flutter Institute

For help on editing package code, view the documentation.

[1.0.3+1] - 2018-08-24

  • Fixing version numbers in the changelog, because I forgot to save it.

[1.0.3] - 2018-08-24

  • Streamlining the Location dependency injection in context.dart
  • Fixing the compiler errors in context.dart related to dart 2
  • Adding an example application for how to use this
  • Updating quiver dependency to match the flutter sdk dependency

[1.0.2] - 2018-08-03

  • Optimizing the Postion class for better comparisons

[1.0.1] - 2018-07-18

  • Removing unused import from the test files

[1.0.0] - 2018-07-17

  • Initial release for sharing location data using InheritedWidget

example/lib/main.dart

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

const MAPS_API_KEY = 'AIzaSyB0vykgvACInKwdBKsrgvJwOVIvC2AHEdU';

void main() => runApp(LocationContextExampleApp());

class LocationContextExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return LocationContext.around(
      MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MapViewPage(),
      ),
    );
  }
}

class MapViewPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final LocationContext loc = LocationContext.of(context);
    final Size size = MediaQuery.of(context).size;

    final List<Widget> children = List();

    if (loc.error != null) {
      children.add(Center(
        child: Text('Error ${loc.error}', style: TextStyle(color: Colors.red)),
      ));
    } else {
      final Position pos = loc.currentLocation;
      if (pos != null) {
        Uri uri = Uri.https('maps.googleapis.com', 'maps/api/staticmap', {
          'center': '${pos.latitude},${pos.longitude}',
          'zoom': '18',
          'size': '${size.width.floor()}x${size.height.floor()}',
          'key': MAPS_API_KEY,
          'markers': 'color:blue|size:small|${pos.latitude},${pos.longitude}',
        });

        children.addAll(<Widget>[
          Expanded(
            child: Image.network(uri.toString()),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Expanded(child: Center(child: Text('Latitude: ${pos.latitude}'))),
              Expanded(child: Center(child: Text('Longitude: ${pos.longitude}'))),
            ],
          ),
        ]);
      } else {
        children.add(Center(child: Text('Location Not Found')));
      }
    }

    return Scaffold(
      appBar: AppBar(
        title: Text('Location Context Example'),
      ),
      body: Column(
        children: children,
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  location_context: ^1.0.3+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:location_context/location_context.dart';
  
Version Uploaded Documentation Archive
1.0.3+1 Aug 24, 2018 Go to the documentation of location_context 1.0.3+1 Download location_context 1.0.3+1 archive
1.0.3 Aug 24, 2018 Go to the documentation of location_context 1.0.3 Download location_context 1.0.3 archive
1.0.2 Aug 4, 2018 Go to the documentation of location_context 1.0.2 Download location_context 1.0.2 archive
1.0.1+1 Aug 3, 2018 Go to the documentation of location_context 1.0.1+1 Download location_context 1.0.1+1 archive
1.0.1 Jul 19, 2018 Go to the documentation of location_context 1.0.1 Download location_context 1.0.1 archive
1.0.0 Jul 17, 2018 Go to the documentation of location_context 1.0.0 Download location_context 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <3.0.0
flutter 0.0.0
location ^1.3.4 1.4.1
quiver ^2.0.0+1 2.0.1
Transitive dependencies
collection 1.14.11
matcher 0.12.4
meta 1.1.6
path 1.6.2
sky_engine 0.0.99
stack_trace 1.9.3
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test