Flutter – My widgets keep getting rebuilt and making http request every time

In my app I have an index screen with some bottom nav that can show or go to another screen on click using setState to change the _selectedIndex and the screen are in a list class IndexPage extends StatefulWidget { const IndexPage({Key? key}) : super(key: key); @override State<IndexPage> createState() => _IndexPageState(); } class _IndexPageState extends… Read More Flutter – My widgets keep getting rebuilt and making http request every time

Simple Flutter Getx code throwing error the improper use of a GetX has been detected

import ‘package:flutter/material.dart’; import ‘package:get/get.dart’; import ‘package:image_picker/image_picker.dart’; import ‘package:reactive_forms/reactive_forms.dart’; class FilePicker extends GetView { final FormControl? control; const FilePicker({ this.control, Key? key, }) : super(key: key); @override Widget build(BuildContext context) { return Obx( () => GestureDetector(onTap: () {}, child: const TextField()), ); } } Error trying to pick a file from gallery. Using Getx for a… Read More Simple Flutter Getx code throwing error the improper use of a GetX has been detected

How to define stream variable in getx package?

I want use rx variable in getx pacakge, how can I define it? import ‘package:get/get.dart’; class InitReportController extends GetxController { int count = 0; } >Solution : You must use this structure. import ‘package:get/get.dart’; class InitReportController extends GetxController { Rx<count> count = 0.obs; void countChange(int i) => count.value = i; } and when you want… Read More How to define stream variable in getx package?

type 'Rx<Text>' is not a subtype of type 'Widget' in type cast<…>

I want to make the Widget obserable in flutter when using get get: ^4.3.8, the controller code like this: class MainController extends GetxController { Widget childWidget = Text("Loading…").obs as Widget; } and the minimal reproduce main.dart look like this: import ‘package:flutter/material.dart’; import ‘package:get/get_state_manager/src/simple/get_state.dart’; import ‘main_controller.dart’; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget… Read More type 'Rx<Text>' is not a subtype of type 'Widget' in type cast<…>

Flutter: How can I hide internacionalization class from getx import

I am using getx as a state management in my protect and I also I am using easy_localization. Now I need to use both of them in one page but tr() is inside get/get_utils/src/extensions/internacionalization.dartand I can’t use both of these packages with together. Now I want to hide this internacionalization from getx import but I… Read More Flutter: How can I hide internacionalization class from getx import

cant translate text with value using GETX in flutter

the problem is that the text has value which declares the day before the text so idk how to translate this text that includes value. untilEventDay = ‘${pDate.difference(DateTime.now()).inDays},days/ until event day’ .tr; in translation page : ,days/ until next event day’: ‘ڕؤژ ماوه‌/ تاوه‌كو ئیڤێنتی داهاتوو’, >Solution : you should separate the value’s string from… Read More cant translate text with value using GETX in flutter

Getx controller not save previous state when back to it's page

I am using getx on my project. On my page, I have a button. when I pressed my button I open a new page: GetBuilder<SearchHomeController>( init: controller, id: ‘dic’, initState: (_) {}, builder: (_) { if (controller.alertTypes != null) { return SliverToBoxAdapter( child: DialogLauncher( context: context, title: "Not Founded", message: "Do you want to Add?",… Read More Getx controller not save previous state when back to it's page

GetX Throwing TypeError when try to build with Obx

I have controller call MenuController class MenuController extends GetxController { var currentCategory = Rx<int>(0); @override void onReady() async { await Future.delayed(const Duration(milliseconds: 2000)); } void setMenuByIndex(int index) { currentCategory.value = index; } } And I’m trying to check selected index from simple Widget like this Obx(() => Text(controller.currentCategory.value.toString())) Getting controller like here final controller =… Read More GetX Throwing TypeError when try to build with Obx