怎么查看方法的入参?比如onTap的入参

来源:8-3 APP首页框架搭建-项目实践【搭了个框架】

MarcoLhc

2020-06-29

      bottomNavigationBar: BottomNavigationBar(
        selectedItemColor: Colors.blue,
        unselectedItemColor: Colors.grey,
        onTap: (index) {
          pageController.jumpToPage(index);
          setState(() {
            _curIndex = index;
          });
        },
	  }

BottomNavigationBar的onTap入参是有index的,这个是从哪里看出来的呢?我点进去看源码也没有相关信息,以后用到不熟悉的方法怎么知道入参呢?

  /// Called when one of the [items] is tapped.
  ///
  /// The stateful widget that creates the bottom navigation bar needs to keep
  /// track of the index of the selected [BottomNavigationBarItem] and call
  /// `setState` to rebuild the bottom navigation bar with the new [currentIndex].
  final ValueChanged<int> onTap;
写回答

1回答

CrazyCodeBoy

2020-06-29

可以看onTap的声明:

  final ValueChanged<int> onTap;

声明中你会发现它有一个int类型的参数,那么index就是它的形参。

0
0

Flutter从入门到进阶 实战携程网App 一网打尽核心技术

解锁Flutter开发新姿势,,系统掌握Flutter开发核心技术。

4788 学习 · 3274 问题

查看课程