'Missing type arguments for generic type 'MaterialPageRoute<dynamic>' (Flutter)

I'm getting this error with flutter_windows_v1.9.0-dev but I don't how to solve it.

Missing type arguments for generic type "MaterialPageRoute< dynamic > ".

Here is my line code

Navigator.push(context, MaterialPageRoute(builder: (BuildContext c)=>UserProfile()));

It underlines MaterialPageRoute and push. But It worked before I update Flutter to the last version.



Solution 1:[1]

@SergioBernal had the correct answer. I'm posting it here for visibility since I almost missed his comment above:

replace MaterialPageRoute with MaterialPageRoute<void>

as in:

 Navigator.push(
        context,
        MaterialPageRoute<void>(builder: (context) => SecondRoute()),
      );

Also, This works for PageRouteBuilder as well as in this example:

Navigator.push(
        context,
        PageRouteBuilder<void>(pageBuilder: () => SchedulingPage5()),
  );

Solution 2:[2]

Just add void in front of MaterialPageRoute

Navigator.push(context, MaterialPageRoute<void>(builder: (BuildContext c)=>UserProfile()));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Blastfurnace