-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
551 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:lotti/blocs/journal/journal_page_cubit.dart'; | ||
import 'package:lotti/classes/journal_entities.dart'; | ||
import 'package:lotti/database/database.dart'; | ||
import 'package:lotti/get_it.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'task_controller.g.dart'; | ||
|
||
@riverpod | ||
class TaskController extends _$TaskController { | ||
TaskController() {} | ||
JournalEntity? _prev; | ||
|
||
@override | ||
create() {} | ||
|
||
@override | ||
Future<Task?> build({required String id}) async { | ||
final entry = ref.watch(entityByIdProvider(id: id)).value; | ||
|
||
if (entry is Task) { | ||
if (entry != _prev) { | ||
debugPrint('TaskController build $id'); | ||
_prev = entry; | ||
return entry; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
|
||
@riverpod | ||
class TaskController1 extends _$TaskController { | ||
TaskController1() { | ||
_controller = StreamController(); | ||
} | ||
late final StreamController<JournalEntity?> _controller; | ||
|
||
@override | ||
Future<Task?> build({required String id}) async { | ||
return null; | ||
} | ||
} | ||
|
||
@riverpod | ||
Stream<JournalEntity?> entityById( | ||
EntityByIdRef ref, { | ||
required String id, | ||
}) { | ||
debugPrint('entityById $id'); | ||
final filter = makeDuplicateFilter<JournalEntity?>(); | ||
return getIt<JournalDb>().watchEntityById(id).asBroadcastStream(); | ||
// .where(filter); | ||
} |
Oops, something went wrong.