Search code examples
flutterruntime-errorflutter-getx

FLUTTER + GETX: The children of `MultiChildRenderObjectElement` must each has an associated render object


I've some code managed with the get package. I'm using GetX widget to display a loading indicator during async operations. Everything works, but in console I see this error logged and I don't understand what the problem is.

return Scaffold(
      appBar: AppBar(
        leading: GetBuilder<FormController>(
          builder: (cValues) => IconButton(
            onPressed: () {
              Timer(
                const Duration(milliseconds: 500),
                cValues.unpick,
              );
              Get.back();
            },
            icon: const Icon(
              Icons.arrow_back,
              color: Colors.black,
            ),
          ),
        ),
        centerTitle: true,
        title: Text(
          'EDIT MODE',
          textAlign: TextAlign.center,
          style: TextStyle(
            fontSize: 28.75,
            fontWeight: FontWeight.bold,
            color: const Color(0xff707070),
          ),
        ),
        backgroundColor: Colors.transparent,
        elevation: 0,
      ),
      body: Stack(
        children: [
/* VARIOUS LAYOUT WIDGETS HERE */
          if (!KeyboardVisibilityProvider.isKeyboardVisible(context))
            ColoredButton(
              alignment: const Alignment(0, 0.9),
              text: 'SAVE',
              onTap: () => _validateAndSubmit(context),
              color: AppColors.red,
            ),
          GetX<FormController>( <== ERROR IS GIVEN AT THIS LINE
            builder: (cValues) => cValues.isFetching.isTrue
                ? CustomLoader(text: cValues.currentOperation.value)
                : nil,
          )
        ],
      ),
    );

Solution

  • Replace nil with Container() and try again.