Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振项目中的大摇大摆_Flutter_Swagger_Flutter Http - Fatal编程技术网

Flutter 颤振项目中的大摇大摆

Flutter 颤振项目中的大摇大摆,flutter,swagger,flutter-http,Flutter,Swagger,Flutter Http,我是一个新的颤振,并试图整合以下图书馆使用招摇在颤振项目。 我迄今为止所采取的步骤: (一) 2) main.dart文件: import 'package:swagger/api.dart'; 3) 在Pubspec.yaml中添加了swagger文件,因此我的项目支持SDK 2.0.0 environment: sdk: ">=2.0.0-dev.68.0 <3.0.0" 环境: sdk:“>=2.0.0-dev.68.0以下是链接swagger API文件的

我是一个新的颤振,并试图整合以下图书馆使用招摇在颤振项目。

我迄今为止所采取的步骤:

(一)

2) main.dart文件:

import 'package:swagger/api.dart';
3) 在Pubspec.yaml中添加了swagger文件,因此我的项目支持SDK 2.0.0

 environment:
      sdk: ">=2.0.0-dev.68.0 <3.0.0"
环境:

sdk:“>=2.0.0-dev.68.0以下是链接swagger API文件的步骤,
1.使用生成dart的客户端文件
2.将
api\u client.dart
文件对
BrowserClient()
的使用替换为
IOClient()
,并导入所需的库。此BrowserClient在我的项目中导致生成错误,因为它包含web依赖项

  class ApiClient {
      String basePath;
      var client = new BrowserClient();//old one
      var client = new IOClient();//should be changed to this

.
.

3.然后创建客户端类以访问API,如下所示

/// Singleton class for ApiClient
class Client {
  ApiClient apiClient;
  AuthApi _authApi;

  AuthApi get authApi => _authApi;
  static final Client _client = Client._initClient();

  factory Client() {
    return _client;
  }

  Client._initClient() {
    apiClient = ApiClient(
      basePath: "http://yourproject.apilink",
    );
    _authApi = AuthApi(apiClient);
  }
}

4.然后

class AuthImpl {
  final Client client;

  AuthImpl(this.client) {}

  Future<User> signIn({
    @required String deviceID,
    @required String deviceType,
    @required String phone,
    @required String password,
  }) async {
    AuthLoginResponse authLoginResponse;
    User user;

    authLoginResponse = await client.authApi
        .authPostLogin(deviceID, deviceType, phone, password);
    user = authLoginResponse.payload;
    return user;
  }}
类AuthImpl{ 最终客户; authinpl(this.client){} 未来签约({ @必需的字符串设备ID, @必需的字符串设备类型, @必需的字符串电话, @必需的字符串密码, })异步的{ AuthLoginResponse AuthLoginResponse; 用户; authLoginResponse=await client.authApi .authPostLogin(设备ID、设备类型、电话、密码); user=authLoginResponse.payload; 返回用户; }}
class AuthImpl {
  final Client client;

  AuthImpl(this.client) {}

  Future<User> signIn({
    @required String deviceID,
    @required String deviceType,
    @required String phone,
    @required String password,
  }) async {
    AuthLoginResponse authLoginResponse;
    User user;

    authLoginResponse = await client.authApi
        .authPostLogin(deviceID, deviceType, phone, password);
    user = authLoginResponse.payload;
    return user;
  }}