kauemurakami / getx_pattern

Design pattern designed to standardize your projects with GetX on Flutter.
https://kauemurakami.github.io/getx_pattern
1k stars 235 forks source link

why you dont getConnect as provider? #34

Closed hanafiahtkj closed 2 years ago

hanafiahtkj commented 2 years ago

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

kauemurakami commented 2 years ago

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.

hanafiahtkj commented 2 years ago

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

kauemurakami commented 2 years ago

Try remove assert and @required

hanafiahtkj commented 2 years ago

thanks you