小编mar*_*mar的帖子

Flutter 闪屏视频播放器

我正在尝试为我的应用程序创建背景视频启动屏幕。目前,我通过运行此代码实现了空白屏幕。

 void main() => runApp(WalkThrough());

class WalkThrough extends StatefulWidget {
  @override
  _WalkThroughState createState() => _WalkThroughState();
}

class _WalkThroughState extends State<WalkThrough> {
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    // Pointing the video controller to our local asset.
    _controller = VideoPlayerController.asset('assets/video.mp4')
      ..initialize().then((_) {
        // Once the video has been loaded we play the video and set looping to true.
        _controller.play();
        _controller.setLooping(true);
        _controller.setVolume(0.0);
        _controller.play();
        // Ensure the first frame is shown after the video is initialized.
        setState(() {});
      });
  }

  @override
  Widget …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-dependencies flutter-layout

7
推荐指数
1
解决办法
6718
查看次数

Flutter 容器不响应手势

如果我有设置宽度/高度手势检测器的空容器不起作用,但如果我添加类似颜色的东西,它就会开始工作。

测试应用:

    import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  click(){
    _counter++;
    print('Clicked times: $_counter');
  }

  @override
  Widget build(BuildContext context) …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-dependencies flutter-layout

0
推荐指数
1
解决办法
1148
查看次数