kauemurakami/getx_pattern

why you dont getConnect as provider?

hanafiahtkj opened this issue · 4 comments

can you teach me example if want using getConnect as provider? and how how to using that provider in my repository?

New GetRouterOutlet implementation: Meditation app
todo-list with Get Storage with state manager and services: todo-list
valorant example state manager with state mixin: examples/valorant-brasil-module-example
blogging example state manager with state mixin and service: Blogging
Another: byebnk

here are some examples most of them have getconnect as a provider.

this is my provider

import 'dart:async';
import 'package:get/get.dart';
import 'package:app_sso_flutter_2/app/data/model/kategori.dart';

const baseUrl = 'xxxx';

class AppsProvider extends GetConnect {
// Get request
Future<Response> getKategoriWithApps() => get(baseUrl);
}

this is my repository

import 'package:app_sso_flutter_2/app/data/provider/apps_api.dart';
import 'package:meta/meta.dart';

class MyRepository {
AppsProvider apiClient;

MyRepository({@required this.apiClient}) : assert(apiClient != null);

getKategoriWithApps() {
return apiClient.getKategoriWithApps();
}
}

========

but i get error in myrepository in this line:

MyRepository({@required this.apiClient}) : assert(apiClient != null);

error:

The parameter 'apiClient' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.

please can you help me

Try remove assert and @required

thanks you