Logo

使用 Amplify DataStore 在 Flutter 中克隆 WhatsApp

关于项目

product-screenshot

内置

入门

要本地运行并启动一个副本,请按照以下简单步骤操作。

先决条件

  • 您的系统应已安装Flutter。
  • 需要AWS账户来配置所有资源。
  • 应已安装AWS Amplify CLI并配置好AWS账户。

安装

  1. 克隆仓库

    git clone https://github.com/GeekyAnts/flutter_amplify_datastore_demo
  2. 安装NPM包

    flutter pub get
  3. 运行Amplify init初始化Amplify项目和应用API以配置资源

    amplify init
    amplify add api
    amplify add auth
    // Choose email and password authentication.
  4. amplify/backend/api/FlutterAmplifyApi/schema.graphql文件中的graphql schema替换为以下内容。

    type ChatRoom
      @model
      @auth(rules: [{ allow: public }])
      @key(name: "byUser", fields: ["userID"]) {
      id: ID!
      otherUserId: String
      otherUserName: String
      userID: ID
      chatId: String
      untitledfield: String
    }
    
    type ChatData @model @auth(rules: [{ allow: public }]) {
      id: ID!
      message: String
      createdAt: AWSDateTime
      chatRoomId: String
      senderId: String
    }
    
    type User @model @auth(rules: [{ allow: public }]) {
      id: ID!
      username: String!
      email: String
      bio: String
      profileImage: String
      isVerified: Boolean
      createdAt: AWSDateTime
      chats: AWSJSON
      ChatRooms: [ChatRoom] @connection(keyName: "byUser", fields: ["id"])
    }

贡献

贡献是开源社区如此美好、激发灵感和创造的源泉。您的任何贡献都备受赞赏

  1. Fork 该项目
  2. 创建您的功能分支 (git checkout -b feature/flutter_amplify_datastore_demo)
  3. 提交您的更改 (git commit -m 'Add some flutter_amplify_datastore_demo')
  4. 推送到分支 (git push origin feature/flutter_amplify_datastore_demo)
  5. 打开一个拉取请求

GitHub

查看 Github