We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import 'package:card_swiper/card_swiper.dart'; import 'package:flutter/material.dart'; import 'package:video_player/video_player.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( home: WrapWidget( videoUris: [ IAC() ], ), ); } } class WrapWidget extends StatefulWidget { const WrapWidget({ super.key, required this.videoUris, }); final List<IAC> videoUris; @override State<WrapWidget> createState() => _WrapWidgetState(); } class _WrapWidgetState extends State<WrapWidget> { @override Widget build(BuildContext context) { return Swiper( itemCount: 2, itemBuilder: (BuildContext context, int index){ if(index==0){ return Placeholder(); }else{ return widget.videoUris[0].a(); } }, // child: widget.videoUris[0].a() ); } } abstract class AC{ Widget a(); } class IAC implements AC{ @override Widget a(){ return const Demo(); } } class Demo extends StatefulWidget { const Demo({super.key}); @override State<Demo> createState() => _DemoState(); } class _DemoState extends State<Demo> { @override void initState() { print("_VideoWidgetNeedDisposeState-initState"); const uri = "https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"; controller = VideoPlayerController.networkUrl(Uri.parse(uri)); initializeVideoPlayerFuture = controller.initialize(); controller.setLooping(true); super.initState(); } late final VideoPlayerController controller; late final Future<void> initializeVideoPlayerFuture; @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder( future: initializeVideoPlayerFuture, builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) { if (snapshot.connectionState == ConnectionState.done) { controller.play(); return Stack( children: [ Center( child: AspectRatio( aspectRatio: controller.value.aspectRatio, child: VideoPlayer(controller), ), ), ], ); }else{ return const Center( child: CircularProgressIndicator(), ); } }, ), floatingActionButton: FloatingActionButton( onPressed: () { controller.play(); }, child: const Icon(Icons.play_circle), ), ); } @override void dispose() { print("_VideoWidgetNeedDisposeState-dispose"); super.dispose(); controller.dispose(); } }
The text was updated successfully, but these errors were encountered:
first swipe to right, then hot restart. you still can hearing video's audio.
Sorry, something went wrong.
No branches or pull requests
Code sample
The text was updated successfully, but these errors were encountered: