giantss Github contribution chart
giantss Github Stats
giantss Most Used Languages

Activity

26 Sep 2022

Giantss

started

Started On 26 Sep 2022 at 05:11:44
Issue Comment

Giantss

getx GetConnect onInit not work

getx GetConnect onInit not working causing this error. Unhandled Exception: Invalid argument(s): No host specified in URI albums/1

Here is a simple example https://github.com/giantss/flutterGetxTest/tree/main/testapp

example:

home_binding.dart

import 'package:get/get.dart';
import 'package:testapp/app/modules/home/providers/home_provider.dart';

import '../controllers/home_controller.dart';

class HomeBinding extends Bindings {
  @override
  void dependencies() {
    Get.lazyPut<HomeController>(
      () => HomeController(),
    );
    Get.lazyPut<HomeProvider>(
          () => HomeProvider(),
    );
  }
} 

home_provider.dart

import 'package:get/get.dart';
import '../home_model.dart';

class HomeProvider extends GetConnect {
  @override
  void onInit() {    // no call
    httpClient.defaultDecoder = (map) {
      if (map is Map<String, dynamic>) return Home.fromJson(map);
      if (map is List) return map.map((item) => Home.fromJson(item)).toList();
    };
    httpClient.baseUrl = 'https://jsonplaceholder.typicode.com/';   
  }

  Future<Home?> getHome(int id) async {
    final response = await get('albums/$id');  // error is thrown here
    return response.body;
  }

  Future<Response<Home>> postHome(Home home) async => await post('home', home);
  Future<Response> deleteHome(int id) async => await delete('home/$id');
} 

pubspec.yaml

name: testapp
version: 1.0.0+1
publish_to: none
description: A new Flutter project.
environment: 
  sdk: '>=2.17.6 <3.0.0'

dependencies: 
  cupertino_icons: ^1.0.2
  get: 4.6.5
  flutter: 
    sdk: flutter

dev_dependencies: 
  flutter_lints: 2.0.1
  flutter_test: 
    sdk: flutter

flutter: 
  uses-material-design: true 

Forked On 26 Sep 2022 at 01:54:03

Giantss

@kauemurakami Thanks a lot for your answer. This is just a very simple demo, and I didn't even write any logic. In theory, this kind of problem should not occur. Is this an official bug? @jonataslaw

Commented On 26 Sep 2022 at 01:54:03

Giantss

A showcase app for the Flutter SDK. Wonderous will educate and entertain as you uncover information about some of the most famous structures in the world.

Forked On 23 Sep 2022 at 06:22:35

Giantss

Chinese character stroke order animations and practice quizzes

Forked On 22 Sep 2022 at 12:39:03

Giantss

:orange_book: 中华新华字典数据库。包括歇后语,成语,词语,汉字。

Forked On 22 Sep 2022 at 12:38:49

Giantss

started

Started On 22 Sep 2022 at 12:38:23
Issue Comment

Giantss

getx GetConnect onInit not work

getx GetConnect onInit not working causing this error. Unhandled Exception: Invalid argument(s): No host specified in URI albums/1

Here is a simple example https://github.com/giantss/flutterGetxTest/tree/main/testapp

example:

home_binding.dart

import 'package:get/get.dart';
import 'package:testapp/app/modules/home/providers/home_provider.dart';

import '../controllers/home_controller.dart';

class HomeBinding extends Bindings {
  @override
  void dependencies() {
    Get.lazyPut<HomeController>(
      () => HomeController(),
    );
    Get.lazyPut<HomeProvider>(
          () => HomeProvider(),
    );
  }
} 

home_provider.dart

import 'package:get/get.dart';
import '../home_model.dart';

class HomeProvider extends GetConnect {
  @override
  void onInit() {    // no call
    httpClient.defaultDecoder = (map) {
      if (map is Map<String, dynamic>) return Home.fromJson(map);
      if (map is List) return map.map((item) => Home.fromJson(item)).toList();
    };
    httpClient.baseUrl = 'https://jsonplaceholder.typicode.com/';   
  }

  Future<Home?> getHome(int id) async {
    final response = await get('albums/$id');  // error is thrown here
    return response.body;
  }

  Future<Response<Home>> postHome(Home home) async => await post('home', home);
  Future<Response> deleteHome(int id) async => await delete('home/$id');
} 

pubspec.yaml

name: testapp
version: 1.0.0+1
publish_to: none
description: A new Flutter project.
environment: 
  sdk: '>=2.17.6 <3.0.0'

dependencies: 
  cupertino_icons: ^1.0.2
  get: 4.6.5
  flutter: 
    sdk: flutter

dev_dependencies: 
  flutter_lints: 2.0.1
  flutter_test: 
    sdk: flutter

flutter: 
  uses-material-design: true 

Forked On 20 Sep 2022 at 01:35:52

Giantss

@giantss put it above your lazyput, that should work.

also, you might want to include the parenthesis on the HomeProvider so it doesn't treat it as a Type instead of an instance.

like so

Get.put(HomeProvider());

Get.lazyPut<HomeController>(
    () => HomeController(),
); 

@jonataslaw Tried it all, still doesn't work. I have a demo example above, can you clone it and help? thank you very much。

Commented On 20 Sep 2022 at 01:35:52
Issue Comment

Giantss

getx GetConnect onInit not work

getx GetConnect onInit not working causing this error. Unhandled Exception: Invalid argument(s): No host specified in URI albums/1

Here is a simple example https://github.com/giantss/flutterGetxTest/tree/main/testapp

example:

home_binding.dart

import 'package:get/get.dart';
import 'package:testapp/app/modules/home/providers/home_provider.dart';

import '../controllers/home_controller.dart';

class HomeBinding extends Bindings {
  @override
  void dependencies() {
    Get.lazyPut<HomeController>(
      () => HomeController(),
    );
    Get.lazyPut<HomeProvider>(
          () => HomeProvider(),
    );
  }
} 

home_provider.dart

import 'package:get/get.dart';
import '../home_model.dart';

class HomeProvider extends GetConnect {
  @override
  void onInit() {    // no call
    httpClient.defaultDecoder = (map) {
      if (map is Map<String, dynamic>) return Home.fromJson(map);
      if (map is List) return map.map((item) => Home.fromJson(item)).toList();
    };
    httpClient.baseUrl = 'https://jsonplaceholder.typicode.com/';   
  }

  Future<Home?> getHome(int id) async {
    final response = await get('albums/$id');  // error is thrown here
    return response.body;
  }

  Future<Response<Home>> postHome(Home home) async => await post('home', home);
  Future<Response> deleteHome(int id) async => await delete('home/$id');
} 

pubspec.yaml

name: testapp
version: 1.0.0+1
publish_to: none
description: A new Flutter project.
environment: 
  sdk: '>=2.17.6 <3.0.0'

dependencies: 
  cupertino_icons: ^1.0.2
  get: 4.6.5
  flutter: 
    sdk: flutter

dev_dependencies: 
  flutter_lints: 2.0.1
  flutter_test: 
    sdk: flutter

flutter: 
  uses-material-design: true 

Forked On 19 Sep 2022 at 10:57:27

Giantss

@giantss You have to use Get.put instead of Get.lazyPut for the provider.

@pratamatama The demo I provided is replaced with the following code and it still doesn't work.

class HomeBinding extends Bindings {
  @override
  void dependencies() {
    Get.lazyPut<HomeController>(
      () => HomeController(),
    );
    Get.put(HomeProvider);
    // Get.lazyPut<HomeProvider>(
    //       () => HomeProvider(),
    // );
  }
} 

Commented On 19 Sep 2022 at 10:57:27
Issue Comment

Giantss

getx GetConnect onInit not work

getx GetConnect onInit not working causing this error. Unhandled Exception: Invalid argument(s): No host specified in URI albums/1

Here is a simple example https://github.com/giantss/flutterGetxTest/tree/main/testapp

example:

home_binding.dart

import 'package:get/get.dart';
import 'package:testapp/app/modules/home/providers/home_provider.dart';

import '../controllers/home_controller.dart';

class HomeBinding extends Bindings {
  @override
  void dependencies() {
    Get.lazyPut<HomeController>(
      () => HomeController(),
    );
    Get.lazyPut<HomeProvider>(
          () => HomeProvider(),
    );
  }
} 

home_provider.dart

import 'package:get/get.dart';
import '../home_model.dart';

class HomeProvider extends GetConnect {
  @override
  void onInit() {    // no call
    httpClient.defaultDecoder = (map) {
      if (map is Map<String, dynamic>) return Home.fromJson(map);
      if (map is List) return map.map((item) => Home.fromJson(item)).toList();
    };
    httpClient.baseUrl = 'https://jsonplaceholder.typicode.com/';   
  }

  Future<Home?> getHome(int id) async {
    final response = await get('albums/$id');  // error is thrown here
    return response.body;
  }

  Future<Response<Home>> postHome(Home home) async => await post('home', home);
  Future<Response> deleteHome(int id) async => await delete('home/$id');
} 

pubspec.yaml

name: testapp
version: 1.0.0+1
publish_to: none
description: A new Flutter project.
environment: 
  sdk: '>=2.17.6 <3.0.0'

dependencies: 
  cupertino_icons: ^1.0.2
  get: 4.6.5
  flutter: 
    sdk: flutter

dev_dependencies: 
  flutter_lints: 2.0.1
  flutter_test: 
    sdk: flutter

flutter: 
  uses-material-design: true 

Forked On 13 Sep 2022 at 10:39:59

Giantss

@jonataslaw Can you help take a look? This problem has been bothering me for a while.

Commented On 13 Sep 2022 at 10:39:59

Giantss

demo

demo

Pushed On 07 Sep 2022 at 08:33:45
Create Branch

Giantss

Description not entered by the user.

On 07 Sep 2022 at 08:10:47
Create Branch

Giantss

Description not entered by the user.

On 07 Sep 2022 at 08:10:46

Giantss

started

Started On 31 Aug 2022 at 07:50:08

Giantss

started

Started On 22 Aug 2022 at 03:40:40

Giantss

completely free for everyone. Its build-in Flutter Dart.

Forked On 16 Aug 2022 at 03:45:04

Giantss

started

Started On 16 Aug 2022 at 03:44:53