Skip to content

Instantly share code, notes, and snippets.

Avatar

Guilherme de Carvalho Carneiro guilhermecarvalhocarneiro

View GitHub Profile
View serializers.py
class AgendamentoSerializer(FieldsListSerializerMixin, ModelSerializer):
fk_profissional = ProfissionalSerializer(read_only=True)
fk_cliente = ClienteSerializer(read_only=True)
fk_servico = ServicoSerializer(read_only=True)
etapa_display = CharField(source="get_etapa_display", read_only=True, allow_null=True, allow_blank=True)
class Meta:
model = Agendamento
View Pessoa CubitState
class PessoaCubit extends Cubit<PessoaState> {
PessoaService _service;
List<PessoaModel> pessoaList;
List<PessoaModel> pessoaDestaqueList;
PessoaCubit() : super(PessoaInitial()) {
_service = PessoaService();
}
@guilhermecarvalhocarneiro
guilhermecarvalhocarneiro / Error Flutter
Created Dec 16, 2020
Erro que está travando a app, apareceu "do nada"
View Error Flutter
The following assertion was thrown resolving an image codec:
Unable to load asset:
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:225:7)
<asynchronous suspension>
#1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:668:31)
#2 AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:651:14)
#3 ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:504:13)
...
@guilhermecarvalhocarneiro
guilhermecarvalhocarneiro / gist:160e78627d13610df254b32fa7c240ae
Created Oct 17, 2020
Erro Psycopg2 (Windows 10 + Django 3.1 + psycopg2-binary==2.8.6)
View gist:160e78627d13610df254b32fa7c240ae
$ python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\guilh\Development\Django\Sige\venv\lib\site-packages\django\db\backends\postgresql\base.py", line 25, in <module>
import psycopg2 as Database
File "C:\Users\guilh\Development\Django\Sige\venv\lib\site-packages\psycopg2\__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: DLL load failed while importing _psycopg: Não foi possível encontrar o módulo especificado.
View Cubit.State.dart
part of 'cubit.dart';
abstract class UsuarioState extends Equatable {
const UsuarioState();
}
class UsuarioInitial extends UsuarioState {
@override
List<Object> get props => [];
}
View example.dart
child: 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 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 => [];
}
You can’t perform that action at this time.