DEV Community

Jonatan Rodríguez
Jonatan Rodríguez

Posted on

Manejo del Estado en una Flutter App

Después de probar Flutter con cierta intensidad en los últimos días rapidamente llegue a la conclusión de que el framework soluciona gran parte de la carga de trabajo en la ui. Tenemos gran cantidad de Widgets para ello. Dicho esto y con lo anterior más que claro, Lo siguiente era pensar... ¿Cómo voy a mantener el estado de mis apps?

Anhelando Apollo Client

En mis desarrollos web uso normalmente ReactJS y para el mantenimiento del estado uso Apollo Client... (tienen que probarlo es una gozada), el caso es que después de haber probado las mieles de Graphql no quiero otra cosa (de momento), pero... la realidad es que Flutter aún es muy nuevo para el gran publico y todavía no existe una solución del equipo de Apollo para Flutter aunque la comunidad ya lo pide!

Flutter Support Request #2756

Intended outcome: Apollo Client support for Dart/Flutter, see https://flutter.io/

Actual outcome: Currently not supported

Motivation: Flutter and Dart are revolutionizing the cross platform mobile app development and would greatly benefit from the Apollo Client. Since Apollo has always maintained the openness to new popular frameworks it would be great to have it support Flutter.

La mejor librería que he visto hasta ahora es graphql-flutter pero aún no han desarrollado la parte del manejo del Estado. (por favor, si estoy equivocado... Díganmelo!!!)

GitHub logo zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.

GraphQL Flutter

A collection of packages to work with graphql server in dart and flutter.

GitHub Workflow Status (branch) Pub Popularity Discord

Introduction

GraphQL brings many benefits, both to the client: devices will need fewer requests, and therefore reduce data usage. And to the programmer: requests are arguable, they have the same structure as the request.

This project combines the benefits of GraphQL with the benefits of Streams in Dart to deliver a high-performance client.

The project took inspiration from the Apollo GraphQL client, great work guys!

Packages

This is a Monorepo which contains the following packages:

Crate Description Version
graphql Client implementation to interact with any graphql server Pub Version (including pre-releases)
graphql_flutter Flutter Widgets wrapper around graphql API Pub Version (including pre-releases)

Utils Tools

Around graphql_flutter are builds awesome tools like:

  1. graphql_flutter_bloc
  2. graphql_codegen
  3. graphql-cache-inspector

Features

✅   Queries, Mutations, and Subscriptions
✅   Query polling and rebroadcasting
✅   In memory and persistent caching
✅   GraphQL Upload
✅   Optimistic results
✅   Modularity
✅  …

Total! que seguramente tendré que tirar de soluciones más clásicas, en Flutter por supuesto tenemos varias opciones, en este repositorio tenemos varios ejemplos:

flutter_architecture_samples

Build Status Build Status codecov

List of Todos Screen

TodoMVC for Flutter!

Flutter provides a lot of flexibility in deciding how to organize and architect your apps. While this freedom is very valuable, it can also lead to apps with large classes, inconsistent naming schemes, as well as mismatching or missing architectures. These types of issues can make testing, maintaining and extending your apps difficult.

The Flutter Architecture Samples project demonstrates strategies to help solve or avoid these common problems. This project implements the same app using different architectural concepts and tools.

You can use the samples in this project as a learning reference, or as a starting point for creating your own apps. The focus of this project is on demonstrating how to structure your code, design your architecture, and the eventual impact of adopting these patterns on testing and maintaining your app You can use the techniques demonstrated here in many different ways to build apps.…

State Management

Seguramente me voy a decantar por Redux, porque me es más familiar... ya os iré contando.

PD: Les recomiendo esta platica de Brian Egan

Top comments (0)