Wayaer / fl_pip

flutter picture-in-picture plugin for ios and android
MIT License
27 stars 14 forks source link

[ios] Fix the the pip auto close. #29

Closed ahyangnb closed 1 week ago

ahyangnb commented 1 week ago

I don't know if issue when the app is in the background, FlutterUi will stop running or black screen directly in README.md say this.

but please try it.

it's been run the PIP in background more than 10 minus after fix in ios without black or dispear.

ahyangnb commented 1 week ago

i got it, it's real flutter ui frezee when background in ios, i'll try to solve it.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';

class PipOverlay extends StatefulWidget {
  const PipOverlay({super.key});

  @override
  State<PipOverlay> createState() => _PipOverlayState();
}

class _PipOverlayState extends State<PipOverlay> {
  RxInt randomInt = 0.obs;
  late Timer _timer;

  @override
  void initState() {
    super.initState();
    _timer = Timer.periodic(Duration(seconds: 1), (timer) {
      randomInt.value =
          DateTime.now().millisecondsSinceEpoch % 100; // Example random value
    });
  }

  @override
  void dispose() {
    _timer.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Obx(() {
          return Text("Flutter Pip ${randomInt.value}");
        }),
      ),
    );
  }
}