dual_screen 0.0.2-dev copy "dual_screen: ^0.0.2-dev" to clipboard
dual_screen: ^0.0.2-dev copied to clipboard

outdated

Flutter plugin for determing whether the device supports dual screen and whether the app is currently spanned across both screen.

example/lib/main.dart

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

import 'package:dual_screen/dual_screen.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool _isDualScreenDevice;
  bool _isAppSpanned;
  bool _isAppSpannedStream;

  @override
  void initState() {
    super.initState();
    DualScreen.isAppSpannedStream().listen(
      (data) => setState(() => _isAppSpannedStream = data),
    );
  }

  Future<void> _updateDualScreenInfo() async {
    bool isDualDevice = await DualScreen.isDualScreenDevice;
    bool isAppSpanned = await DualScreen.isAppSpanned;

    if (!mounted) return;

    setState(() {
      _isDualScreenDevice = isDualDevice;
      _isAppSpanned = isAppSpanned;
    });
  }

  @override
  Widget build(BuildContext context) => MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: Text('Dual screen device example'),
          ),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('Dual device: ${_isDualScreenDevice ?? 'Unknown'}'),
                SizedBox(height: 8),
                Text('App spanned: ${_isAppSpanned ?? 'Unknown'}'),
                SizedBox(height: 8),
                RaisedButton(
                  child: Text('Manually determine dual device and app spanned'),
                  onPressed: () => _updateDualScreenInfo(),
                ),
                SizedBox(height: 64),
                Text('App spanned stream: ${_isAppSpannedStream ?? 'Unknown'}'),
              ],
            ),
          ),
        ),
      );
}
146
likes
0
points
5.31k
downloads

Publisher

verified publishermicrosoft.com

Weekly Downloads

Flutter plugin for determing whether the device supports dual screen and whether the app is currently spanned across both screen.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on dual_screen