@@ -11,27 +11,31 @@ final MaterialColor themeMaterialColor =
1111 const Color .fromRGBO (48 , 49 , 60 , 1 ));
1212
1313void main () {
14- runApp (GeolocatorWidget ());
14+ runApp (const GeolocatorWidget ());
1515}
1616
1717/// Example [Widget] showing the functionalities of the geolocator plugin
1818class GeolocatorWidget extends StatefulWidget {
19+ /// Creates a new GeolocatorWidget.
20+ const GeolocatorWidget ({Key ? key}) : super (key: key);
21+
1922 /// Utility method to create a page with the Baseflow templating.
2023 static ExamplePage createPage () {
21- return ExamplePage (Icons .location_on, (context) => GeolocatorWidget ());
24+ return ExamplePage (
25+ Icons .location_on, (context) => const GeolocatorWidget ());
2226 }
2327
2428 @override
2529 _GeolocatorWidgetState createState () => _GeolocatorWidgetState ();
2630}
2731
2832class _GeolocatorWidgetState extends State <GeolocatorWidget > {
29- static final String _kLocationServicesDisabledMessage =
33+ static const String _kLocationServicesDisabledMessage =
3034 'Location services are disabled.' ;
31- static final String _kPermissionDeniedMessage = 'Permission denied.' ;
32- static final String _kPermissionDeniedForeverMessage =
35+ static const String _kPermissionDeniedMessage = 'Permission denied.' ;
36+ static const String _kPermissionDeniedForeverMessage =
3337 'Permission denied forever.' ;
34- static final String _kPermissionGrantedMessage = 'Permission granted.' ;
38+ static const String _kPermissionGrantedMessage = 'Permission granted.' ;
3539
3640 final GeolocatorPlatform _geolocatorPlatform = GeolocatorPlatform .instance;
3741 final List <_PositionItem > _positionItems = < _PositionItem > [];
@@ -70,25 +74,25 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
7074 },
7175 itemBuilder: (context) => [
7276 if (Platform .isIOS)
73- PopupMenuItem (
77+ const PopupMenuItem (
7478 child: Text ("Get Location Accuracy" ),
7579 value: 1 ,
7680 ),
7781 if (Platform .isIOS)
78- PopupMenuItem (
82+ const PopupMenuItem (
7983 child: Text ("Request Temporary Full Accuracy" ),
8084 value: 2 ,
8185 ),
82- PopupMenuItem (
86+ const PopupMenuItem (
8387 child: Text ("Open App Settings" ),
8488 value: 3 ,
8589 ),
8690 if (Platform .isAndroid)
87- PopupMenuItem (
91+ const PopupMenuItem (
8892 child: Text ("Open Location Settings" ),
8993 value: 4 ,
9094 ),
91- PopupMenuItem (
95+ const PopupMenuItem (
9296 child: Text ("Clear" ),
9397 value: 5 ,
9498 ),
@@ -123,7 +127,7 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
123127 return ListTile (
124128 title: Text (positionItem.displayValue,
125129 textAlign: TextAlign .center,
126- style: TextStyle (
130+ style: const TextStyle (
127131 color: Colors .white,
128132 fontWeight: FontWeight .bold,
129133 )),
@@ -134,7 +138,7 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
134138 tileColor: themeMaterialColor,
135139 title: Text (
136140 positionItem.displayValue,
137- style: TextStyle (color: Colors .white),
141+ style: const TextStyle (color: Colors .white),
138142 ),
139143 ),
140144 );
@@ -148,8 +152,8 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
148152 FloatingActionButton (
149153 child: (_positionStreamSubscription == null ||
150154 _positionStreamSubscription! .isPaused)
151- ? Icon (Icons .play_arrow)
152- : Icon (Icons .pause),
155+ ? const Icon (Icons .play_arrow)
156+ : const Icon (Icons .pause),
153157 onPressed: _toggleListening,
154158 tooltip: (_positionStreamSubscription == null )
155159 ? 'Start position updates'
@@ -160,12 +164,12 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
160164 ),
161165 sizedBox,
162166 FloatingActionButton (
163- child: Icon (Icons .my_location),
167+ child: const Icon (Icons .my_location),
164168 onPressed: _getCurrentPosition,
165169 ),
166170 sizedBox,
167171 FloatingActionButton (
168- child: Icon (Icons .bookmark),
172+ child: const Icon (Icons .bookmark),
169173 onPressed: _getLastKnownPosition,
170174 ),
171175 ],
@@ -246,7 +250,6 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
246250
247251 void _updatePositionList (_PositionItemType type, String displayValue) {
248252 _positionItems.add (_PositionItem (type, displayValue));
249- print (displayValue);
250253 setState (() {});
251254 }
252255
0 commit comments