Skip to content

Instantly share code, notes, and snippets.


Guilherme de Carvalho Carneiro guilhermecarvalhocarneiro

View GitHub Profile
View Bloc_CubitConsumer.dart
BlocConsumer<UsuarioCubit, UsuarioState>(
listener: (context, state) {
if (state is UsuarioProcessState) {
child: Container(
width: double.infinity,
child: Column(
children: [
View main.dart
class MyApp extends StatelessWidget {
// This widget is the root of your application.
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
View usuario_cubit.dart
import 'package:bloc/bloc.dart';
import 'package:cubit_example/apps/usuario/model.dart';
import 'package:equatable/equatable.dart';
import '../service.dart';
part 'usuario_state.dart';
class UsuarioCubit extends Cubit<UsuarioState> {
UsuarioService _service;
View usuario_state.dart
part of 'usuario_cubit.dart';
abstract class UsuarioState extends Equatable {
const UsuarioState();
class UsuarioInitial extends UsuarioState {
List<Object> get props => [];
View pubspec.yaml
name: cubit_example
description: A new Flutter project.
publish_to: "none" # Remove this line if you wish to publish to
version: 1.0.0+1
sdk: ">=2.7.0 <3.0.0"
* Copyright (c) 2020.
* Desenvolvido por.
* Guilherme de Carvalho Carneiro
* Twitter ->
* Linkedin ->
* GitHub ->
View gist:477c6aefeedcc5e4815ecccc734c9823
return SliverAppBar(
backgroundColor: Colors.white,
pinned: false,
bottom: PreferredSize(
preferredSize: Size.fromHeight(15),
child: Container(
const EdgeInsets.only(top: 2, left: 12, right: 12, bottom: 10),
child: Stack(
class BaseManager(models.Manager):
"""Sobrescrevendo o Manager padrão. Nesse Manager
os registros não são apagados do banco de dados
apenas desativados, atribuindo ao campo deleted = True e
enabled = True
def get_queryset(self):
"""Sobrescrevendo a queryset para filtrar os
registros que foram marcados como deleted
View atrativo_model.dart
class Atrativo {
int id;
String nome;
String endereco;
double latitude;
double longitude;
String pontuacao;
int curtidas;
List<String> imagens;
View atrativo_bloc.dart
class AtrativoBloc extends BlocBase {
final _controller = BehaviorSubject<List<Atrativo>>();
get stream =>;
getAtrativos() async {
try {
var _cidade = await CidadeBloc.getCidadeEscolhida();
if ( != null){
List<Atrativo> _atrativos = await Atrativo.getAtrativos(;
You can’t perform that action at this time.