Skip to content

Instantly share code, notes, and snippets.

@umuieme
Created December 13, 2022 09:06
Show Gist options
  • Save umuieme/72ae031c12a703c3e9e0757fb709e292 to your computer and use it in GitHub Desktop.
Save umuieme/72ae031c12a703c3e9e0757fb709e292 to your computer and use it in GitHub Desktop.
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