Share objects between aqueduct and flutter

422

You won't be able to combine Aqueduct and Flutter in the same project - they have different compilation targets, and both take advantage of those targets.

The general approach is to use aqueduct document to create an OpenAPI document from your code, then use an OpenAPI code generator to build your client-side code. This approach is preferable to sharing code between the server and clients. Code can be shared between browser and mobile targets. It is a good idea to avoid having one type that represents the database, server and client definition of an object. A client type and a database table mapping will eventually have differences that will be difficult to manage.

Share:
422
UNeverNo
Author by

UNeverNo

Quotes I like: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilisation. A good programmer is someone who looks both ways before crossing a one-way street. The most likely way for the world to be destroyed, most experts agree, is by accident. That’s where we come in; we’re computer professionals. We cause accidents. Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

Updated on December 08, 2022

Comments

  • UNeverNo
    UNeverNo over 1 year

    I'm using aqueduct as a server where I defined an user object and extended it to make use of OAuth:

    class ManagedUser extends ManagedObject<_User> implements _User, ManagedAuthResourceOwner<_User>
    

    After finishing the work on aqueduct I started working on the flutter app and wanted to use the ManagedUser-object in flutter as well, that's why I thought about putting it into a separate project.

    The problem I face now (during deployment) is the following:

    ERROR:flutter/shell/common/shell.cc(184)] Dart Error: error: import of dart:mirrors with --enable-mirrors=false
    

    As I read here Dart Error: error: import of dart:mirrors with --enable-mirrors=false it's because flutter doesn't seem to support parts of aqueduct (which I unfortunately need in my shared project to use ManagedObject).

    So I'm kinda stuck here. What are my options? I really don't like to map all objects again on the flutter side.