1- library mobility_app ;
1+ library ;
22
33import 'dart:async' ;
44import 'package:flutter/material.dart' ;
@@ -14,13 +14,10 @@ void main() => runApp(const MyApp());
1414
1515Widget entry (String key, String value, Icon icon) {
1616 return Container (
17- padding: const EdgeInsets .all (2 ),
18- margin: const EdgeInsets .all (3 ),
19- child: ListTile (
20- leading: icon,
21- title: Text (key),
22- trailing: Text (value),
23- ));
17+ padding: const EdgeInsets .all (2 ),
18+ margin: const EdgeInsets .all (3 ),
19+ child: ListTile (leading: icon, title: Text (key), trailing: Text (value)),
20+ );
2421}
2522
2623String formatDate (DateTime date) => '${date .year }/${date .month }/${date .day }' ;
@@ -55,9 +52,7 @@ class MyApp extends StatelessWidget {
5552 Widget build (BuildContext context) {
5653 return MaterialApp (
5754 title: 'Mobility Features Example' ,
58- theme: ThemeData (
59- primarySwatch: Colors .blue,
60- ),
55+ theme: ThemeData (primarySwatch: Colors .blue),
6156 home: const HomePage (title: 'Mobility Features Example' ),
6257 );
6358 }
@@ -123,16 +118,19 @@ class HomePageState extends State<HomePage> {
123118
124119 // map from [LocationDto] to [LocationSample]
125120 Stream <LocationSample > locationSampleStream = locationStream.map (
126- (location) => LocationSample (
127- GeoLocation (location.latitude, location.longitude),
128- DateTime .now ()));
121+ (location) => LocationSample (
122+ GeoLocation (location.latitude, location.longitude),
123+ DateTime .now (),
124+ ),
125+ );
129126
130127 // provide the [MobilityFeatures] instance with the LocationSample stream
131128 await MobilityFeatures ().startListening (locationSampleStream);
132129
133130 // start listening to incoming MobilityContext objects
134- mobilitySubscription =
135- MobilityFeatures ().contextStream.listen (onMobilityContext);
131+ mobilitySubscription = MobilityFeatures ().contextStream.listen (
132+ onMobilityContext,
133+ );
136134 }
137135
138136 Future <bool > isLocationAlwaysGranted () async {
@@ -204,55 +202,63 @@ class HomePageState extends State<HomePage> {
204202 children: < Widget > [
205203 entry ("Stops" , "${_mobilityContext .stops ?.length }" , stopIcon),
206204 entry ("Moves" , "${_mobilityContext .moves ?.length }" , moveIcon),
207- entry ("Significant Places" ,
208- "${_mobilityContext .numberOfSignificantPlaces }" , placeIcon),
209205 entry (
210- "Home Stay" ,
211- _mobilityContext.homeStay == null || _mobilityContext.homeStay! < 0
212- ? "?"
213- : "${(_mobilityContext .homeStay ! * 100 ).toStringAsFixed (1 )}%" ,
214- homeStayIcon),
206+ "Significant Places" ,
207+ "${_mobilityContext .numberOfSignificantPlaces }" ,
208+ placeIcon,
209+ ),
210+ entry (
211+ "Home Stay" ,
212+ _mobilityContext.homeStay == null || _mobilityContext.homeStay! < 0
213+ ? "?"
214+ : "${(_mobilityContext .homeStay ! * 100 ).toStringAsFixed (1 )}%" ,
215+ homeStayIcon,
216+ ),
215217 entry (
216- "Distance Traveled" ,
217- "${(_mobilityContext .distanceTraveled ! / 1000 ).toStringAsFixed (2 )} km" ,
218- distanceTraveledIcon),
218+ "Distance Traveled" ,
219+ "${(_mobilityContext .distanceTraveled ! / 1000 ).toStringAsFixed (2 )} km" ,
220+ distanceTraveledIcon,
221+ ),
219222 entry (
220- "Normalized Entropy" ,
221- "${_mobilityContext .normalizedEntropy ?.toStringAsFixed (2 )}" ,
222- entropyIcon),
223+ "Normalized Entropy" ,
224+ "${_mobilityContext .normalizedEntropy ?.toStringAsFixed (2 )}" ,
225+ entropyIcon,
226+ ),
223227 entry (
224- "Location Variance" ,
225- "${(111.133 * _mobilityContext .locationVariance !).toStringAsFixed (5 )} km" ,
226- varianceIcon),
228+ "Location Variance" ,
229+ "${(111.133 * _mobilityContext .locationVariance !).toStringAsFixed (5 )} km" ,
230+ varianceIcon,
231+ ),
227232 ],
228233 );
229234 }
230235
231236 List <Widget > get contentNoFeatures {
232237 return [
233238 Container (
234- margin: const EdgeInsets .all (25 ),
235- child: const Text (
236- 'Move around to start generating features' ,
237- style: TextStyle (fontSize: 20 ),
238- ))
239+ margin: const EdgeInsets .all (25 ),
240+ child: const Text (
241+ 'Move around to start generating features' ,
242+ style: TextStyle (fontSize: 20 ),
243+ ),
244+ ),
239245 ];
240246 }
241247
242248 List <Widget > get contentFeaturesReady {
243249 return [
244250 Container (
245- margin: const EdgeInsets .all (25 ),
246- child: Column (children: [
247- const Text (
248- 'Statistics for today,' ,
249- style: TextStyle (fontSize: 20 ),
250- ),
251+ margin: const EdgeInsets .all (25 ),
252+ child: Column (
253+ children: [
254+ const Text ('Statistics for today,' , style: TextStyle (fontSize: 20 )),
251255 Text (
252256 formatDate (_mobilityContext.date! ),
253257 style: const TextStyle (fontSize: 20 , color: Colors .blue),
254258 ),
255- ])),
259+ ],
260+ ),
261+ ),
256262 Expanded (child: featuresOverview),
257263 ];
258264 }
@@ -274,16 +280,16 @@ class HomePageState extends State<HomePage> {
274280 }
275281
276282 Widget get navBar => BottomNavigationBar (
277- onTap: onTabTapped,
278- currentIndex: _currentIndex,
279- type: BottomNavigationBarType .fixed,
280- items: const [
281- BottomNavigationBarItem (icon: featuresIcon, label: 'Features' ),
282- BottomNavigationBarItem (icon: stopIcon, label: 'Stops' ),
283- BottomNavigationBarItem (icon: placeIcon, label: 'Places' ),
284- BottomNavigationBarItem (icon: moveIcon, label: 'Moves' )
285- ],
286- );
283+ onTap: onTabTapped,
284+ currentIndex: _currentIndex,
285+ type: BottomNavigationBarType .fixed,
286+ items: const [
287+ BottomNavigationBarItem (icon: featuresIcon, label: 'Features' ),
288+ BottomNavigationBarItem (icon: stopIcon, label: 'Stops' ),
289+ BottomNavigationBarItem (icon: placeIcon, label: 'Places' ),
290+ BottomNavigationBarItem (icon: moveIcon, label: 'Moves' ),
291+ ],
292+ );
287293
288294 @override
289295 Widget build (BuildContext context) {
@@ -312,10 +318,7 @@ class HomePageState extends State<HomePage> {
312318 ];
313319
314320 return Scaffold (
315- appBar: AppBar (
316- backgroundColor: Colors .teal,
317- title: Text (widget.title),
318- ),
321+ appBar: AppBar (backgroundColor: Colors .teal, title: Text (widget.title)),
319322 body: pages[_currentIndex],
320323 bottomNavigationBar: navBar,
321324 );
0 commit comments