如何使用颤动画中画? [英] How do you do picture in picture using flutter?
问题描述
有什么方法可以通过flutter应用程序进行画中画吗?就像您在观看视频并导航到另一个应用程序时YouTube所做的那样.
Is there any way to do picture in picture with a flutter app? Kind of like what YouTube does when you're watching a video and navigate to another app.
他们在这里谈论它: https://youtu.be/hBPd2q2dmXY
They talk about it here: https://youtu.be/hBPd2q2dmXY
我搜索了它,但找不到任何有关它的信息
I searched for it and couldn't find any info about it
推荐答案
该功能称为画中画模式",与画中画"相比,它在Google上应该容易得多. 有一个flutter包,但我还没有尝试过(不幸的是,它似乎只是android) https://pub.dartlang.org/packages/flutter_android_pip
The feature is called "PiP mode" which should be a lot easier to google than "picture in picture". There is a flutter package but I have not tried it (also appears to be android only unfortunately) https://pub.dartlang.org/packages/flutter_android_pip
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_android_pip/flutter_android_pip.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
// initPlatformState();
}
/*
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
platformVersion = await FlutterAndroidPip.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}*/
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Plugin example app'),
),
body: new Center(
child: new RaisedButton(
child: new Text("press"),
onPressed: () {
FlutterAndroidPip.enterPictureInPictureMode;
},
),
),
),
);
}
}
这篇关于如何使用颤动画中画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!