title: How to implement GeoLocator StreamController and get Data through screens - Flutter
body: <p>I implemented this package <a href="https://pub.dev/packages/geolocator" rel="nofollow noreferrer">https://pub.dev/packages/geolocator</a> but I don't know how to use StreamSubscription.</p>
  <pre><code>class LocationService{
  
    UserLocation _userLocation;
    
    StreamController&lt;UserLocation&gt; locationUserController;
  
    var geolocator = Geolocator();
    var locationOptions = LocationOptions(accuracy: LocationAccuracy.high, distanceFilter: 10);
  
    LocationService(){
  
      geolocator.getPositionStream(locationOptions).listen(
      (Position position) {
          if (position != null){
            locationUserController.add(UserLocation(
              latitude: position.latitude,
              longitude: position.longitude
            ));
          }
      });
    }
  }
  </code></pre>
  <p>I implemented GeoLocator.That set values into a model class <strong>UserLocation</strong>.</p>
  <pre><code>class UserLocation{
    final double latitude;
    final double longitude;
  
    UserLocation({this.latitude, this.longitude});
  }
  </code></pre>
  <p>How I access this <strong>UserLocation</strong> every time that values change?</p>
  <p>I need to acess this data in <strong>MapsScreen</strong></p>
  <pre><code>class MyApp extends StatelessWidget {
    // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
      //my try. I don't know what I'm doing
      //StreamProvider&lt;UserLocation&gt;(
      //  create: (_) =&gt; LocationService().locationUserController,
      //)
      return MaterialApp(
        title: 'UnMatch',
        theme: ThemeData(
          primaryColor: ThemeColor.nero,
        ),
        initialRoute: '/home',
        routes: {
          '/home' : (context) =&gt; MapScreen(),
          '/login' : (context) =&gt; Login()
        }
      );  
    }
  }
  </code></pre>
  <p>Can you explain and insert in the code how should I do? I'm very confused with it...</p>