Skip to content

Commit c03179b

Browse files
authored
style: update to use the linter flutter_lints (#67)
1 parent 4ced00a commit c03179b

6 files changed

+26
-22
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A Flutter plugin for fetching Firestore documents with read from cache first the
77
[![MIT License](https://img.shields.io/github/license/zeshuaro/firestore_cache.svg)](https://github.com/zeshuaro/firestore_cache/blob/master/LICENSE)
88
[![GitHub Actions](https://github.com/zeshuaro/firestore_cache/actions/workflows/analyze_test.yml/badge.svg)](https://github.com/zeshuaro/firestore_cache/actions/workflows/analyze_test.yml)
99
[![codecov](https://codecov.io/gh/zeshuaro/firestore_cache/branch/main/graph/badge.svg)](https://codecov.io/gh/zeshuaro/firestore_cache)
10-
[![pedantic](https://img.shields.io/badge/style-pedantic-40c4ff.svg)](https://github.com/google/pedantic)
10+
[![style: flutter_lints](https://img.shields.io/badge/style-flutter__lints-4BC0F5.svg)](https://pub.dev/packages/flutter_lints)
1111

1212
This plugin is mainly designed for applications using the `DocumentReference.get()` and `Query.get()` methods in the `cloud_firestore` plugin, and is implemented with read from cache first then server.
1313

analysis_options.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include: package:pedantic/analysis_options.1.11.0.yaml
1+
include: package:flutter_lints/flutter.yaml

example/lib/main.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import 'package:flutter/material.dart';
66
void main() async {
77
WidgetsFlutterBinding.ensureInitialized();
88
await Firebase.initializeApp();
9-
runApp(MyApp());
9+
runApp(const MyApp());
1010
}
1111

1212
class MyApp extends StatelessWidget {
13+
const MyApp({Key? key}) : super(key: key);
14+
1315
// This widget is the root of your application.
1416
@override
1517
Widget build(BuildContext context) {
@@ -19,12 +21,14 @@ class MyApp extends StatelessWidget {
1921
primarySwatch: Colors.blue,
2022
visualDensity: VisualDensity.adaptivePlatformDensity,
2123
),
22-
home: MyHomePage(),
24+
home: const MyHomePage(),
2325
);
2426
}
2527
}
2628

2729
class MyHomePage extends StatefulWidget {
30+
const MyHomePage({Key? key}) : super(key: key);
31+
2832
@override
2933
_MyHomePageState createState() => _MyHomePageState();
3034
}
@@ -44,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
4448
@override
4549
Widget build(BuildContext context) {
4650
return Scaffold(
47-
appBar: AppBar(title: Text('Firestore Cache Demo')),
51+
appBar: AppBar(title: const Text('Firestore Cache Demo')),
4852
body: Center(
4953
child: Column(
5054
mainAxisAlignment: MainAxisAlignment.center,
@@ -73,7 +77,7 @@ class _MyHomePageState extends State<MyHomePage> {
7377
);
7478
}
7579

76-
return CircularProgressIndicator();
80+
return const CircularProgressIndicator();
7781
},
7882
);
7983
}
@@ -99,7 +103,7 @@ class _MyHomePageState extends State<MyHomePage> {
99103
);
100104
}
101105

102-
return CircularProgressIndicator();
106+
return const CircularProgressIndicator();
103107
},
104108
);
105109
}
@@ -112,8 +116,8 @@ class _MyHomePageState extends State<MyHomePage> {
112116
}
113117

114118
Future<QuerySnapshot<Map<String, dynamic>>> _getDocs() async {
119+
const cacheField = 'updatedAt';
115120
final cacheDocRef = _firestore.doc('status/status');
116-
final cacheField = 'updatedAt';
117121
final query = _firestore.collection('posts');
118122
final snapshot = await FirestoreCache.getDocuments(
119123
query: query,

example/pubspec.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ environment:
2121
sdk: ">=2.12.0 <3.0.0"
2222

2323
dependencies:
24-
flutter:
25-
sdk: flutter
26-
firestore_cache:
27-
path: ../
2824
cloud_firestore: ^3.0.0
2925
firebase_core: ^1.0.2
26+
firestore_cache:
27+
path: ../
28+
flutter:
29+
sdk: flutter
3030

3131
dev_dependencies:
32+
flutter_lints: ^1.0.4
3233
flutter_test:
3334
sdk: flutter
34-
pedantic: ^1.11.0
3535

3636
# For information on the generic Dart part of this file, see the
3737
# following page: https://dart.dev/tools/pub/pubspec

pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ environment:
88
sdk: ">=2.12.0 <3.0.0"
99

1010
dependencies:
11+
cloud_firestore: ^3.0.0
1112
flutter:
1213
sdk: flutter
13-
cloud_firestore: ^3.0.0
1414
shared_preferences: ^2.0.0
1515

1616
dev_dependencies:
17+
build_runner: ^2.0.0
18+
flutter_lints: ^1.0.4
1719
flutter_test:
1820
sdk: flutter
19-
build_runner: ^2.0.0
2021
mocktail: ^0.1.2
21-
pedantic: ^1.11.0

test/firestore_cache_test.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class MockDocumentSnapshot<Map> extends Mock implements DocumentSnapshot<Map> {}
2323
class MockSnapshotMetadata extends Mock implements SnapshotMetadata {}
2424

2525
void main() {
26+
const cacheField = 'updatedAt';
2627
final data = {'firestore': 'cache'};
27-
final cacheField = 'updatedAt';
2828
final mockCacheDocRef = MockDocumentReference<Map<String, dynamic>>();
2929
final mockCacheSnapshot = MockDocumentSnapshot<Map<String, dynamic>>();
3030

@@ -174,7 +174,7 @@ void main() {
174174
SharedPreferences.setMockInitialValues({
175175
cacheField: now.toIso8601String(),
176176
});
177-
final updatedAt = now.subtract(Duration(seconds: 1));
177+
final updatedAt = now.subtract(const Duration(seconds: 1));
178178
when(() => mockCacheSnapshot.data()).thenReturn({
179179
cacheField: Timestamp.fromDate(updatedAt),
180180
});
@@ -212,7 +212,7 @@ void main() {
212212
SharedPreferences.setMockInitialValues({
213213
cacheField: now.toIso8601String(),
214214
});
215-
final updatedAt = now.subtract(Duration(seconds: 1));
215+
final updatedAt = now.subtract(const Duration(seconds: 1));
216216
when(() => mockCacheSnapshot.data()).thenReturn({
217217
cacheField: Timestamp.fromDate(updatedAt),
218218
});
@@ -252,7 +252,7 @@ void main() {
252252
SharedPreferences.setMockInitialValues({
253253
cacheField: now.toIso8601String(),
254254
});
255-
final updatedAt = now.subtract(Duration(seconds: 1));
255+
final updatedAt = now.subtract(const Duration(seconds: 1));
256256
when(() => mockCacheSnapshot.data()).thenReturn({
257257
cacheField: Timestamp.fromDate(updatedAt),
258258
});
@@ -271,7 +271,7 @@ void main() {
271271
SharedPreferences.setMockInitialValues({
272272
cacheField: now.toIso8601String(),
273273
});
274-
final updatedAt = now.add(Duration(seconds: 1));
274+
final updatedAt = now.add(const Duration(seconds: 1));
275275
when(() => mockCacheSnapshot.data()).thenReturn({
276276
cacheField: Timestamp.fromDate(updatedAt),
277277
});
@@ -290,7 +290,7 @@ void main() {
290290
SharedPreferences.setMockInitialValues({
291291
cacheField: now.toIso8601String(),
292292
});
293-
final updatedAt = now.add(Duration(seconds: 1));
293+
final updatedAt = now.add(const Duration(seconds: 1));
294294
when(() => mockCacheSnapshot.data()).thenReturn({
295295
cacheField: updatedAt.toIso8601String(),
296296
});

0 commit comments

Comments
 (0)