on the documentation they use it like this :
class WelcomePage extends GetView<WelcomeController> {
const WelcomePage({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Obx(() => SizedBox(
width: 360.w,
height: 780.w,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
PageView(
scrollDirection: Axis.horizontal,
reverse: false,
onPageChanged: (index) {},
controller: PageController(
initialPage: 0, keepPage: false, viewportFraction: 1),
pageSnapping: true,
physics: const ClampingScrollPhysics(),
children: const [],
)
],
),
)),
);
}
}
but I keep having this error "A value of type 'Null' can't be assigned to a parameter of type 'Widget Function()' in a const constructor. Try using a subtype, or removing the keyword 'const'." error in the constructor of
Obx( () => )
I want to fix this issue and understand why i got this error.
you have to put some observable
value inside the obx for example in your getx controller you have bool isLoading = false.obs;
that you need to add anywhere inside the widget that wrapped by Obx
or it will throws an error