Flutter Navigator.of(context).pop vs Navigator.pop(context) difference

后端 未结 2 1221
夕颜
夕颜 2020-12-17 11:19

What\'s the difference between Navigator.of(context).pop and Navigator.pop(context)?

To me both seems to do the same work, what is the actu

2条回答
  •  执念已碎
    2020-12-17 11:28

    There is no difference between the two, source code confirms this. Calling

    Navigator.pop(context)
    

    actually calls

    Navigator.of(context).pop()
    

    Source code:

    static bool pop(BuildContext context, [ dynamic result ]) {
      return Navigator.of(context).pop(result);
    }
    

提交回复
热议问题