mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 23:08:59 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -28,10 +28,8 @@ class FirebaseEntryApi implements EntryApi {
|
||||
|
||||
@override
|
||||
Stream<List<Entry>> subscribe(String categoryId) {
|
||||
var snapshots = _categoriesRef
|
||||
.document('$categoryId')
|
||||
.collection('entries')
|
||||
.snapshots();
|
||||
var snapshots =
|
||||
_categoriesRef.document(categoryId).collection('entries').snapshots();
|
||||
var result = snapshots.map((querySnapshot) {
|
||||
return querySnapshot.documents.map((snapshot) {
|
||||
return Entry.fromJson(snapshot.data)..id = snapshot.documentID;
|
||||
@@ -54,7 +52,7 @@ class FirebaseEntryApi implements EntryApi {
|
||||
@override
|
||||
Future<Entry> insert(String categoryId, Entry entry) async {
|
||||
var document = await _categoriesRef
|
||||
.document('$categoryId')
|
||||
.document(categoryId)
|
||||
.collection('entries')
|
||||
.add(entry.toJson());
|
||||
return await get(categoryId, document.documentID);
|
||||
@@ -62,8 +60,7 @@ class FirebaseEntryApi implements EntryApi {
|
||||
|
||||
@override
|
||||
Future<List<Entry>> list(String categoryId) async {
|
||||
var entriesRef =
|
||||
_categoriesRef.document('$categoryId').collection('entries');
|
||||
var entriesRef = _categoriesRef.document(categoryId).collection('entries');
|
||||
var querySnapshot = await entriesRef.getDocuments();
|
||||
var entries = querySnapshot.documents
|
||||
.map((doc) => Entry.fromJson(doc.data)..id = doc.documentID)
|
||||
@@ -110,7 +107,7 @@ class FirebaseCategoryApi implements CategoryApi {
|
||||
|
||||
@override
|
||||
Future<Category> delete(String id) async {
|
||||
var document = _categoriesRef.document('$id');
|
||||
var document = _categoriesRef.document(id);
|
||||
var categories = await get(document.documentID);
|
||||
|
||||
await document.delete();
|
||||
@@ -120,7 +117,7 @@ class FirebaseCategoryApi implements CategoryApi {
|
||||
|
||||
@override
|
||||
Future<Category> get(String id) async {
|
||||
var document = _categoriesRef.document('$id');
|
||||
var document = _categoriesRef.document(id);
|
||||
var snapshot = await document.get();
|
||||
return Category.fromJson(snapshot.data)..id = snapshot.documentID;
|
||||
}
|
||||
@@ -143,7 +140,7 @@ class FirebaseCategoryApi implements CategoryApi {
|
||||
|
||||
@override
|
||||
Future<Category> update(Category category, String id) async {
|
||||
var document = _categoriesRef.document('$id');
|
||||
var document = _categoriesRef.document(id);
|
||||
await document.setData(category.toJson());
|
||||
var snapshot = await document.get();
|
||||
return Category.fromJson(snapshot.data)..id = snapshot.documentID;
|
||||
|
||||
@@ -20,11 +20,11 @@ class MockDashboardApi implements DashboardApi {
|
||||
|
||||
/// Creates a [MockDashboardApi] filled with mock data for the last 30 days.
|
||||
Future<void> fillWithMockData() async {
|
||||
await Future<void>.delayed(Duration(seconds: 1));
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
var category1 = await categories.insert(Category('Coffee (oz)'));
|
||||
var category2 = await categories.insert(Category('Running (miles)'));
|
||||
var category3 = await categories.insert(Category('Git Commits'));
|
||||
var monthAgo = DateTime.now().subtract(Duration(days: 30));
|
||||
var monthAgo = DateTime.now().subtract(const Duration(days: 30));
|
||||
|
||||
for (var category in [category1, category2, category3]) {
|
||||
for (var i = 0; i < 30; i++) {
|
||||
@@ -37,8 +37,8 @@ class MockDashboardApi implements DashboardApi {
|
||||
}
|
||||
|
||||
class MockCategoryApi implements CategoryApi {
|
||||
Map<String, Category> _storage = {};
|
||||
StreamController<List<Category>> _streamController =
|
||||
final Map<String, Category> _storage = {};
|
||||
final StreamController<List<Category>> _streamController =
|
||||
StreamController<List<Category>>.broadcast();
|
||||
|
||||
@override
|
||||
@@ -74,6 +74,7 @@ class MockCategoryApi implements CategoryApi {
|
||||
return category..id = id;
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<List<Category>> subscribe() => _streamController.stream;
|
||||
|
||||
void _emit() {
|
||||
@@ -82,8 +83,8 @@ class MockCategoryApi implements CategoryApi {
|
||||
}
|
||||
|
||||
class MockEntryApi implements EntryApi {
|
||||
Map<String, Entry> _storage = {};
|
||||
StreamController<_EntriesEvent> _streamController =
|
||||
final Map<String, Entry> _storage = {};
|
||||
final StreamController<_EntriesEvent> _streamController =
|
||||
StreamController.broadcast();
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user