STEP3: Controller

  • Steps

    Step 1 : controller

    
                         import 'package:flutter/cupertino.dart';
                        import 'package:get/get.dart';
                       
                       
    
                        class BranchController extends GetxController {
                          @override
                          void onInit() {
                            super.onInit();
    
                             
    
                          }
    
                          updatePanel() {
                              
                          }
    
    
                        }
    
                        
    extends from GetxController

    Step 2: UI

    
                        import 'package:flutter/material.dart';
                        import 'package:get/get.dart';
                        import 'package:getx_restaurant/controllers/branch_controller.dart';
    
                        class BranchScreen extends StatelessWidget {
                          BranchScreen({Key? key}) : super(key: key);
    
    
                          @override
                          Widget build(BuildContext context) {
                            Get.put(BranchController());
                            return Scaffold(
    
                              body: Center(
                                child: Text(
                                  'Add',
                                  style: TextStyle(fontSize: 20.0),
                                ),
                              ),
                            );
                          }
                        }
    
    
                    

    Step 3: define route in main.dart

    
                     import 'package:getx_restaurant/screens/branch.dart'; 
    
                     .... 
                     .... 
    
                     getPages: [
                        GetPage(name: '/branch', page: () =>  BranchScreen())
                    ]
                     
                    

    Step 4: call route

    onTap of button in side_menu.dart

    
                    onTap: () => Get.offAndToNamed('/branch'),