Skip to content

Instantly share code, notes, and snippets.

Avatar

Guilherme de Carvalho Carneiro guilhermecarvalhocarneiro

View GitHub Profile
View Bloc_CubitConsumer.dart
BlocConsumer<UsuarioCubit, UsuarioState>(
listener: (context, state) {
if (state is UsuarioProcessState) {
FlutterToast(context).showToast(
child: Container(
color: Colors.blue[200],
width: double.infinity,
child: Column(
children: [
LinearProgressIndicator(),
View main.dart
...
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
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 {
@override
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 pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
View explorar.page.dart
/*
* Copyright (c) 2020.
*
* Desenvolvido por.
* Guilherme de Carvalho Carneiro
* guilherme.carvalho.carneiro@gmail.com
*
* Twitter -> https://twitter.com/GCarneiro
* Linkedin -> https://www.linkedin.com/in/guilhermecarvalho
* GitHub -> https://github.com/guilhermecarvalhocarneiro
View gist:477c6aefeedcc5e4815ecccc734c9823
return SliverAppBar(
backgroundColor: Colors.white,
pinned: false,
bottom: PreferredSize(
preferredSize: Size.fromHeight(15),
child: Container(
padding:
const EdgeInsets.only(top: 2, left: 12, right: 12, bottom: 10),
child: Stack(
alignment: Alignment.center,
View models.py
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 => _controller.stream;
getAtrativos() async {
try {
var _cidade = await CidadeBloc.getCidadeEscolhida();
if (_cidade.id != null){
List<Atrativo> _atrativos = await Atrativo.getAtrativos(_cidade.id);
_controller.sink.add(_atrativos);
You can’t perform that action at this time.