Bryan DigitalBry
 · COO @ Till Always

Show active page icon color

Actions & Logic

I want to know how to show a different color for the icon the current page is on. For example if I am on the home page, I want to show the home icon in a different color.

I know I could use an appstate variable and onclick update it and than compare but than the problem is, what if the user uses swipe back to navigate back. Or he uses a go back button.

The best solution would be having a custom action "getCurrentPageRoute" that gets called onPage init and updates the app state.

Anyone has an idea how to write this action? I have tried this before but that always returned "".

Future<String> getCurrentRoute(BuildContext context) async {
  final route = ModalRoute.of(context);
  if (route != null) {
    return route.settings.name ?? '';
  }
  return "Unknown";
}

Thanks in advance!

What have you tried so far?
Future<String> getCurrentRoute(BuildContext context) async {
  final route = ModalRoute.of(context);
  if (route != null) {
    return route.settings.name ?? '';
  }
  return "Unknown";
}

Did you check FlutterFlow's Documentation for this topic?
Yes
3
4 replies