flutter - 在屏幕水龙头上显示应用栏或平面按钮

标签 flutter dart

我有一个视频播放器,并且有一个自定义按钮可以返回。我想在屏幕上显示该按钮,然后在1或2秒钟后隐藏。可以是透明的应用栏,可在屏幕上显示并点按并隐藏,并且该应用栏包含自定义按钮

最佳答案

输出:

enter image description here

完整代码:

void main() => runApp(MaterialApp(home: YourPage()));

class YourPage extends StatefulWidget {
  @override
  _YourPageState createState() => _YourPageState();
}

class _YourPageState extends State<YourPage> {
  bool _showControls = false; // set it to false initially

  _showAndHideControls() {
    // show controls the moment user tapped on screen
    setState(() => _showControls = true);

    // after 2 seconds, hide the controls
    Timer(Duration(seconds: 2), () {
      setState(() => _showControls = false);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _showControls ? AppBar(title: Text("AppBar")) : null,
      body: Center(
        child: RaisedButton(
          child: Text("Click me"),
          onPressed: _showAndHideControls,
        ),
      ),
    );
  }
}

关于flutter - 在屏幕水龙头上显示应用栏或平面按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58138179/

相关文章:

flutter - 将已完成的 future 传递给 FutureBuilder 时避免单帧等待状态

ios - 当应用程序在后台运行或关闭时,Flutter Firebase Messaging 在 IOS 上不起作用

dart - flutter 中选择的轨道单选按钮

Flutter : PageController. 页面在使用它构建 PageView 之前无法访问

flutter - flutter :凸起的按钮宽度问题

flutter - 如何在通知消息中显示多于一行(flutter_local_notifications程序包)

image - Flutter web Image.network旋转图片

flutter - Http请求发送了一个空的正文

javascript - 在 Dart 中 .callMethod 返回后如何调用 .then?

string - 将字符串转换为参数类型File Flutter