generated from nain93/flutter_boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 컨텐츠 생성시 해시태그 추가
- Loading branch information
Showing
13 changed files
with
617 additions
and
508 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:moa_app/models/hashtag_model.dart'; | ||
import 'package:moa_app/repositories/hashtag_repository.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'hashtag_provider.g.dart'; | ||
|
||
/// AsyncNotifierProvider | ||
// @Riverpod(keepAlive: true) | ||
@riverpod | ||
class Hashtag extends _$Hashtag { | ||
Future<List<HashtagModel>> fetchItem() async { | ||
var data = HashtagRepository.instance.getHashtagList(); | ||
return data; | ||
} | ||
|
||
@override | ||
Future<List<HashtagModel>> build() async { | ||
return fetchItem(); | ||
} | ||
|
||
Future<List<HashtagModel>?> addHashtag({ | ||
required HashtagModel hashtag, | ||
}) async { | ||
state = const AsyncValue.loading(); | ||
|
||
state = await AsyncValue.guard(() async { | ||
// await ItemRepository.instance.addItem(item: item); | ||
var data = await fetchItem(); | ||
return [hashtag, ...data]; | ||
}); | ||
|
||
return state.value; | ||
} | ||
} |
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
Oops, something went wrong.