Integation Tutorial

  1. Create a State Like this

    class HomeState {
    	int? count;
     	HomeState({ this.count,});
    	HomeState copyWith({int? count}) {
         	return HomeState(count: count ?? this.count);
       }
     }
    
  2. Then import'package:flutter_obx/flutter_obx.dart';

  3. After importin the plagin create controller like this

    Obx <HomeState> homeController=Obx <HomeState>(
    value:HomeState(
    count:0,
    ));
    
  4. 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}', ),
                     ],
                   ),
                 );
               }
    
  5. For update value

    homeController.emit(homeController.obs.copyWith(count:count+1));
    
  6. github example

     https://github.com/arijit121/custom_state_manager
    

Libraries

flutter_obx