Skip to content

Commit ef91d24

Browse files
Fix analysis
1 parent aa72e89 commit ef91d24

File tree

4 files changed

+37
-50
lines changed

4 files changed

+37
-50
lines changed

example/analysis_options.yaml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
1-
# This file configures the analyzer, which statically analyzes Dart code to
2-
# check for errors, warnings, and lints.
3-
#
4-
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5-
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6-
# invoked from the command line by running `flutter analyze`.
7-
8-
# The following line activates a set of recommended lints for Flutter apps,
9-
# packages, and plugins designed to encourage good coding practices.
101
include: package:flutter_lints/flutter.yaml
112

123
linter:
13-
# The lint rules applied to this project can be customized in the
14-
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15-
# included above or to enable additional rules. A list of all available lints
16-
# and their documentation is published at https://dart.dev/lints.
17-
#
18-
# Instead of disabling a lint rule for the entire project in the
19-
# section below, it can also be suppressed for a single line of code
20-
# or a specific dart file by using the `// ignore: name_of_lint` and
21-
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22-
# producing the lint.
234
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26-
27-
# Additional information about this file can be found at
28-
# https://dart.dev/guides/language/analysis-options

example/lib/main.dart

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ Future<void> main() async {
3939

4040
@override
4141
class MyApp extends StatefulWidget {
42+
const MyApp({Key? key}) : super(key: key);
43+
4244
@override
43-
_MyAppState createState() => _MyAppState();
45+
MyAppState createState() => MyAppState();
4446
}
4547

46-
class _MyAppState extends State<MyApp> {
48+
class MyAppState extends State<MyApp> {
4749
var isTracking = false;
4850

4951
Timer? _timer;
@@ -69,51 +71,47 @@ class _MyAppState extends State<MyApp> {
6971
appBar: AppBar(
7072
title: const Text('Plugin example app'),
7173
),
72-
body: Container(
74+
body: SizedBox(
7375
width: double.infinity,
7476
child: Column(
7577
children: [
7678
Expanded(
7779
child: Column(
7880
children: [
7981
MaterialButton(
80-
child: const Text('Request location permission'),
8182
onPressed: _requestLocationPermission,
83+
child: const Text('Request location permission'),
8284
),
8385
if (Platform.isAndroid) ...[
84-
const Text(
85-
'Permission on android is only needed starting from sdk 33.'),
86+
const Text('Permission on android is only needed starting from sdk 33.'),
8687
],
8788
MaterialButton(
88-
child: const Text('Request Notification permission'),
8989
onPressed: _requestNotificationPermission,
90+
child: const Text('Request Notification permission'),
9091
),
9192
MaterialButton(
9293
child: const Text('Send notification'),
93-
onPressed: () =>
94-
sendNotification('Hello from another world'),
94+
onPressed: () => sendNotification('Hello from another world'),
9595
),
9696
MaterialButton(
97-
child: const Text('Start Tracking'),
9897
onPressed: isTracking
9998
? null
10099
: () async {
101-
await BackgroundLocationTrackerManager
102-
.startTracking();
100+
await BackgroundLocationTrackerManager.startTracking();
103101
setState(() => isTracking = true);
104102
},
103+
child: const Text('Start Tracking'),
105104
),
106105
MaterialButton(
107-
child: const Text('Stop Tracking'),
108106
onPressed: isTracking
109107
? () async {
110108
await LocationDao().clear();
111109
await _getLocations();
112-
await BackgroundLocationTrackerManager
113-
.stopTracking();
110+
await BackgroundLocationTrackerManager.stopTracking();
114111
setState(() => isTracking = false);
115112
}
116113
: null,
114+
child: const Text('Stop Tracking'),
117115
),
118116
],
119117
),
@@ -125,8 +123,8 @@ class _MyAppState extends State<MyApp> {
125123
),
126124
const Text('Locations'),
127125
MaterialButton(
128-
child: const Text('Refresh locations'),
129126
onPressed: _getLocations,
127+
child: const Text('Refresh locations'),
130128
),
131129
Expanded(
132130
child: Builder(
@@ -188,8 +186,7 @@ class _MyAppState extends State<MyApp> {
188186

189187
void _startLocationsUpdatesStream() {
190188
_timer?.cancel();
191-
_timer = Timer.periodic(
192-
const Duration(milliseconds: 250), (timer) => _getLocations());
189+
_timer = Timer.periodic(const Duration(milliseconds: 250), (timer) => _getLocations());
193190
}
194191
}
195192

@@ -220,15 +217,12 @@ class LocationDao {
220217

221218
SharedPreferences? _prefs;
222219

223-
Future<SharedPreferences> get prefs async =>
224-
_prefs ??= await SharedPreferences.getInstance();
220+
Future<SharedPreferences> get prefs async => _prefs ??= await SharedPreferences.getInstance();
225221

226222
Future<void> saveLocation(BackgroundLocationUpdateData data) async {
227223
final locations = await getLocations();
228-
locations.add(
229-
'${DateTime.now().toIso8601String()} ${data.lat},${data.lon}');
230-
await (await prefs)
231-
.setString(_locationsKey, locations.join(_locationSeparator));
224+
locations.add('${DateTime.now().toIso8601String()} ${data.lat},${data.lon}');
225+
await (await prefs).setString(_locationsKey, locations.join(_locationSeparator));
232226
}
233227

234228
Future<List<String>> getLocations() async {

example/pubspec.lock

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ packages:
2323
path: ".."
2424
relative: true
2525
source: path
26-
version: "1.4.3"
26+
version: "1.5.0"
2727
boolean_selector:
2828
dependency: transitive
2929
description:
@@ -93,6 +93,14 @@ packages:
9393
description: flutter
9494
source: sdk
9595
version: "0.0.0"
96+
flutter_lints:
97+
dependency: "direct dev"
98+
description:
99+
name: flutter_lints
100+
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
101+
url: "https://pub.dev"
102+
source: hosted
103+
version: "5.0.0"
96104
flutter_local_notifications:
97105
dependency: "direct main"
98106
description:
@@ -167,6 +175,14 @@ packages:
167175
url: "https://pub.dev"
168176
source: hosted
169177
version: "3.0.1"
178+
lints:
179+
dependency: transitive
180+
description:
181+
name: lints
182+
sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
183+
url: "https://pub.dev"
184+
source: hosted
185+
version: "5.1.1"
170186
matcher:
171187
dependency: transitive
172188
description:
@@ -469,5 +485,5 @@ packages:
469485
source: hosted
470486
version: "6.5.0"
471487
sdks:
472-
dart: ">=3.5.0 <4.0.0"
488+
dart: ">=3.6.0 <4.0.0"
473489
flutter: ">=3.24.0"

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
dev_dependencies:
1818
flutter_test:
1919
sdk: flutter
20+
flutter_lints: ^5.0.0
2021

2122
flutter:
2223
uses-material-design: true

0 commit comments

Comments
 (0)