0

I'm using VRouter for flutter web routing. When I click on a button to go to next route it shows the new route for a brief moment and then it's vanished. You can see in gif below it comes for a second and then goes away..

Problem is that due to this I'm not able to nevigate back to previous page

enter image description here

Here is my routings

class AppRouters extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return VRouter(
      title: "Portal",
      debugShowCheckedModeBanner: true,
      mode: VRouterMode.history,
      logs: VLogs.info,
      routes: [
        VWidget(path: '/', widget: LoginPage()),
        VWidget(path: '/home', widget: HomePage()),
        tagVGuard(),
        HrVGuard(),
      ],
    );
  }

  VGuard tagVGuard() => VGuard(
        beforeEnter: (vRedirector) async {
          String? check = await UserController.getUserType();
          return check == 'tag' ? null : vRedirector.to('/');
        },
        stackedRoutes: [
          VWidget(path: '/tag', widget: TagDashboardPage()),
          VWidget(path: '/tag/candidates', widget: CandidateListPage()),
          VWidget(path: '/tag/employee', widget: EmployeeListPage()),
        ],
      );

And here is my page which is causing problem

class EmployeeListPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "EmployeeListPage",
      home: Scaffold(
        appBar: MyAppBar("EmployeeListPage"),
        body: Body(),
      ),
    );
  }
}

class Body extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: ApiService.getAllEmployees(),
      builder: (BuildContext context, AsyncSnapshot snapshot) {
        if (snapshot.hasError) {
          return Text("ERROR: ${snapshot.error}");
        }
        if (snapshot.hasData) {
          return GridBody(snapshot.data);
        }
        return Text("Loading DATA");
      },
    );
  }
}

class GridBody extends StatelessWidget {
  final List<EmployeeModel> employeeList;

  GridBody(this.employeeList);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SingleChildScrollView(
        child: Wrap(
          spacing: 10,
          runSpacing: 10,
          children: List.generate(
            employeeList.length,
            (index) => GridCard(employeeList[index]),
          ),
        ),
      ),
    );
  }
}

class GridCard extends StatelessWidget {
  final EmployeeModel employee;

  GridCard(this.employee);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.black26,
      width: 400.0,
      height: 100.0,
      child: Column(
        children: [
          Text(employee.id.toString()),
          Text(employee.name),
          Text(employee.role),
          Text(employee.email),
        ],
      ),
    );
  }
}
Akshat Tamrakar
  • 2,193
  • 2
  • 13
  • 21
  • Hi, VRouter dev here. Could you specify: `Problem is that due to this I'm not able to navigate back to previous page`? Do you mean using the browser back button, or the app bar, or something else? – Lulupointu Oct 15 '21 at 19:07
  • Actually both, browser back button is not working and if we just create a simple button to navigate back it also doesn't work. – Akshat Tamrakar Oct 23 '21 at 06:33
  • Oh I might know. You have a nested `MaterialApp`. Change it to `VMaterialApp` and let me know if it works :) – Lulupointu Oct 23 '21 at 09:20

0 Answers0