floating 0.1.1 copy "floating: ^0.1.1" to clipboard
floating: ^0.1.1 copied to clipboard

PlatformAndroid
outdated

Picture in Picture mode management for Flutter. Available only for Android since web and iOS does not natively support such mode.

example/lib/main.dart

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

import 'package:floating/floating.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool isPipEnabled, isPipSupported;

  @override
  void initState() {
    super.initState();
    checkPipSupport();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> checkPipSupport() async {
    final isPipSupported = await Floating.isPipAvailable;
    final isPipEnabled = await Floating.isInPipMode;
    setState(() {
      this.isPipSupported = isPipSupported;
      this.isPipEnabled = isPipEnabled;
    });
  }

  Future<void> enablePip() async {
    final enabledSuccessfully = await Floating.enablePip();
    print('PiP enabled? $enabledSuccessfully');
    await checkPipSupport();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Floating example app'),
        ),
        body: Center(
          child: Text(
              'PiP available: $isPipSupported\nPiP enabled: $isPipEnabled'),
        ),
        floatingActionButton: isPipSupported ?? false
            ? FloatingActionButton.extended(
                onPressed: enablePip,
                label: Text('Enable PiP'),
                icon: const Icon(Icons.picture_in_picture),
              )
            : null,
      ),
    );
  }
}
155
likes
140
pub points
92%
popularity

Publisher

verified publisherwrbl.xyz

Picture in Picture mode management for Flutter. Available only for Android since web and iOS does not natively support such mode.

Repository (GitLab)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on floating