aws-amplify / aws-amplify/amplify-codegen

Support Amplify Codegen In Pure Dart Projects

Open
#858 2 comments 2 reactions 0 assignees View on GitHub
feature-request
Dominant language
TypeScript
Stars
59
Forks
64
PR merge metrics
No merged PRs in 30d

Description

### Describe the feature you'd like to request

It would be nice to have the ability to leverage features of Amplify Gen 2 (particularly the graphql model gen) in pure Dart packages, in addition to in Flutter projects. This would allow devs to integrate new Amplify features in projects and create packages that could be used in multiple Flutter apps, instead of being bound to a single app.

Currently, this is not possible because of how GraphQL model code is generated into Dart. Specifically, this generated constructor passes in a Flutter app, but throws a `field_initializer_not_assignable` error in a Dart app:

```dart
const Todo._internal({required this.id, content, createdAt, updatedAt}): _content = content, _createdAt = createdAt, _updatedAt = updatedAt;
```

### Describe the solution you'd like

It would be nice if the codegen that generates Dart code from the backend schema generates code that is supported in pure Dart packages.

### Describe alternatives you've considered

The only alternative I can think of would be to only use Amplify on Flutter apps, not Dart packages, which would require repeating schema definitions across multiple Dart projects, and prohibit abstracting model generation within app architecture.

### Additional context

_No response_

### Is this something that you'd be interested in working on?

- [ ] 👋 I may be able to implement this feature request

### Would this feature include a breaking change?

- [ ] ⚠️ This feature might incur a breaking change

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.