kAppBar function

AppBar kAppBar({
  1. Widget? titleWidget,
  2. Widget? leading,
  3. Function? onBack,
  4. Color backgroundColor = Colors.transparent,
  5. bool centerTitle = true,
  6. bool isLightSystemUi = false,
})

自带返回按钮和返回事件,标题剧中

Implementation

AppBar kAppBar(
    {Widget? titleWidget,
    Widget? leading,
    Function? onBack,
    Color backgroundColor = Colors.transparent,
    bool centerTitle = true,
    bool isLightSystemUi = false}) {
  SystemUiOverlayStyle style;
  if (isLightSystemUi) {
    style = const SystemUiOverlayStyle(
      // Brightness.light 状态栏字体颜色(白色)
      statusBarBrightness: Brightness.light,
      statusBarIconBrightness: Brightness.light, // 状态栏字体颜色(黑色)
      statusBarColor: Colors.transparent, // 状态栏背景色
    );
  } else {
    style = const SystemUiOverlayStyle(
      // Brightness.light 状态栏字体颜色(白色)
      statusBarBrightness: Brightness.dark,
      statusBarIconBrightness: Brightness.dark, // 状态栏字体颜色(黑色)
      statusBarColor: Colors.transparent, // 状态栏背景色
    );
  }
  return AppBar(
    systemOverlayStyle: style,
    title: titleWidget,
    centerTitle: centerTitle,
    backgroundColor: backgroundColor,
    elevation: 0,
    //appbar的阴影
    leading: leading,
  );
}