Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
973 B
4
Indexable
Never
//GETTING DATA EXAMPLE
  Future<List<WeeklyItem>?> getHomePackages() async {
    final request = NetworkRequest(
        type: NetworkRequestType.GET,
        path: 'homePackages',
        data: NetworkRequestBody.json(
          {},
        ),
        headers: {},
        queryParams: {});
    // Execute a request and convert response to your model:
    final response = await networkService.execute(
      request,
      HomePackageModel
          .fromJson, // <- Function to convert API response to your model
      onReceiveProgress: (count, total) {},
      onSendProgress: (count, total) {},
    );
    response.maybeWhen(
        ok: (authResponse) {
          return authResponse.data.weekly;
        },
        badRequest: (info) {},
        invalidParameters: (invalidParamsinfo) {},
        noAccess: (info) {},
        noAuth: (info) {},
        notFound: (info) {},
        noData: (info) {},
        conflict: (conflictinfo) {},
        orElse: () {});
  }