Created
December 13, 2022 09:06
-
-
Save umuieme/72ae031c12a703c3e9e0757fb709e292 to your computer and use it in GitHub Desktop.
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
import 'package:equatable/equatable.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'package:meta/meta.dart'; | |
part '$statefile$'; | |
class $cubitName$Cubit extends Cubit<$cubitName$State> { | |
final $repositoryName$ _repository; | |
$cubitName$Cubit(this._repository) : super($cubitName$Initial()); | |
Future<void> $functionName$() async { | |
emit($cubitName$LoadInProgress()); | |
final response = await $end$; | |
if (!isClosed) { | |
response.fold( | |
(error) => emit($cubitName$LoadFailure(error)), | |
(data) => emit($cubitName$LoadSuccess(data)), | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment