Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.6k stars 406 forks source link

Cannot decipher customRouteBuilder documentation #1783

Open Adam-Langley opened 1 year ago

Adam-Langley commented 1 year ago

I'm trying to implement a CustomRoute and use the customRouteBuilder, however the documentation is pretty light. I've been told I need to do this so I can pop a settings dialog floating over ANY screen (I need a global settings dialog).

https://github.com/Milad-Akarie/auto_route_library#custom-route-builder

CustomRoute(page: CustomPage, customRouteBuilder:    
 (BuildContext context, Widget child, CustomPage<T> page){                  
     return PageRouteBuilder(                  
     fullscreenDialog: page.fullscreenDialog,                  
     // this is important                  
     settings: page,                  
     pageBuilder: (,__,___) => child);                  
} ) 

What is this 'CustomPage' class? Is that supposed to be provided by auto_route? VS Code intellisense isn't helping here as it's just a mess of intellisense errors and I cannot figure out what I'm supposed to supply here. There are no examples on using this in the examples/tests folders.

moshOntong-IT commented 1 year ago

In my case:

 CustomRoute(
      page: OrganizationNewRoute.page,
      path: '/organization/new',
      customRouteBuilder: <OrganizationNewRoute>(BuildContext context,
          Widget child, AutoRoutePage<OrganizationNewRoute> page) {
        return PageRouteBuilder(
          fullscreenDialog: page.fullscreenDialog,
          settings: page,
          pageBuilder: (_, __, ___) {
            return SizedBox(height: 200, width: 200, child: child);
          },
        );
      },
    ),
This is how you can implement or utilize the CustomRoute, basically  the CustomPage it indicates your Generated Page