flutter_obx

Last updated:

0 purchases

flutter_obx Image
flutter_obx Images
Add to Cart

Description:

flutter obx

Integation Tutorial #


Create a State Like this
class HomeState {
int? count;
HomeState({ this.count,});
HomeState copyWith({int? count}) {
return HomeState(count: count ?? this.count);
}
}
copied to clipboard


Then import'package:flutter_obx/flutter_obx.dart';


After importin the plagin create controller like this
Obx <HomeState> homeController=Obx <HomeState>(
value:HomeState(
count:0,
));
copied to clipboard


Ater this use ObxProvider for reflect value in ui.
ObxProvider <HomeState>(
obxController:homeController,
builder: (BuildContext context, HomeState value, Widget? child) {
return SizedBox(
width:MediaQuery.of(context).size.width,
child:Column(
mainAxisAlignment:MainAxisAlignment.center,
children:<Widget>[
const Text( 'You have pushed the button this many times:',),
Text('${value.count}', ),
],
),
);
}
copied to clipboard


For update value
homeController.emit(homeController.obs.copyWith(count:count+1));
copied to clipboard


github example
https://github.com/arijit121/custom_state_manager
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.