flutter 移动 前端 Python Android Javaios

Flutter之Offstage组件

2019-02-14  本文已影响2人  习惯了_就好
/**
 * 控制child是否显示
 *
    当offstage为true,控件隐藏; 当offstage为false,显示;
    当Offstage不可见的时候,如果child有动画等,需要手动停掉,Offstage并不会停掉动画等操作。

    const Offstage({ Key key, this.offstage = true, Widget child })
 */
String showText = "hide";
  bool isOff = false;


body: Container(
          margin: EdgeInsets.only(top: 50.0),
          child: Offstage(
            offstage: isOff,
            child: Text("Offstage组件"),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: onButtonClickListener,
          child: Text(showText),
        )


void onButtonClickListener() {
    setState(() {
      isOff = !isOff;
    });
    if (isOff) {
      showText = "show";
    } else {
      showText = "hide";
    }
  }
上一篇下一篇

猜你喜欢

热点阅读