【问题标题】:How to pass arguments to main function如何将参数传递给主函数
【发布时间】:2020-02-09 02:05:42
【问题描述】:

在著名的flutter_architecture_samples repo 中,也正是在这个main.dart 中,main 函数需要 2 个参数:

void main({
  @required TodosInteractor todosInteractor,
  @required UserRepository userRepository,
}) {
  runApp(Injector(
    todosInteractor: todosInteractor,
    userRepository: userRepository,
    child: TodosBlocProvider(
      bloc: TodosListBloc(todosInteractor),
      child: MaterialApp(...

这是我第一次看到带有参数的颤振主函数,有人可以解释一下吗?尤其是你应该如何向它传递参数。

【问题讨论】:

    标签: flutter


    【解决方案1】:

    没有办法做到这一点,因为当您在设备上启动应用程序时,也没有传递任何参数。 你可以检查这个How do you pass arguments from command line to main in Flutter/Dart?

    【讨论】:

      猜你喜欢
      • 2020-06-27
      • 2015-10-30
      • 1970-01-01
      • 2016-12-31
      • 2013-01-27
      • 2017-08-02
      • 2021-08-15
      • 2016-05-20
      相关资源
      最近更新 更多