location_context 1.0.3+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

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


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 {
  Widget build(BuildContext context) {
    return LocationContext.around(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        home: MapViewPage(),

class MapViewPage extends StatelessWidget {
  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) {
        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}',

            child: Image.network(uri.toString()),
            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:

  location_context: ^1.0.3+1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub 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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/src/context.dart. (-0.50 points)

Analysis of lib/src/context.dart reported 1 hint:

line 35 col 20: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (location).

Package is getting outdated. (-40.82 points)

The package was last published 73 weeks ago.


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 2.3.5
quiver ^2.0.0+1 2.1.2+1
Transitive dependencies
collection 1.14.11 1.14.12
matcher 0.12.6
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
stack_trace 1.9.3
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies