首页 > 解决方案 > 未处理的异常:FormatException:使用注册 Firebase 方法时出现意外字符(在字符 1 处)

问题描述

所以我正在尝试使用 firebase 实时数据库发布,我的注册功能如下所示:

  Future<void> signup(String email, String password) async {
    var url = Uri.https(
      'identitytoolkit.googleapis.com',
      '/v1/accounts:signUp?key=[API_KEY]',
    );

    final response = await http.post(
      url,
      body: json.encode(
        {
          'email': email,
          'password': password,
          'returnSecureToken': true,
        },
      ),
    );
    print(json.decode(response.body));
  }

我得到的完整错误是:

E/flutter(7313):[错误:flutter/lib/ui/ui_dart_state.cc(186)]未处理的异常:FormatException:意外字符(在字符1处)E/flutter(7313):E/flutter(7313):^ E/颤振(7313):

似乎我正在通过 html 但它需要 json ,但文档没有提到这一点,而且我正在遵循的课程使用它并且它工作正常,知道吗?

标签: firebaseflutterdartfirebase-authentication

解决方案


推荐阅读