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

outdated

Flutter plugin supports to run on two screens. It's basically a tablet connected to another screen via an HDMI or Wireless

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:presentation_displays/PresentationDisplays.dart';
import 'package:presentation_displays/displays_manager.dart';
import 'package:presentation_displays/display.dart';

Route<dynamic> generateRoute(RouteSettings settings) {
  switch (settings.name) {
    case '/':
      return MaterialPageRoute(builder: (_) => DisplayManagerScreen());
    case 'presentation':
      return MaterialPageRoute(builder: (_) => PresentationScreen());
    default:
      return MaterialPageRoute(
          builder: (_) =>
              Scaffold(
                body: Center(
                    child: Text('No route defined for ${settings.name}')),
              ));
  }
}

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: generateRoute,
      initialRoute: '/',
    );
  }
}

class Button extends StatelessWidget {
  Button(this.title, this.function);

  final String title;
  final Function function;

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(4.0),
      child: RaisedButton(
        onPressed: function,
        child: Text(title, style: TextStyle(fontSize: 40),),
      ),
    );
  }
}

/// Main Screen
class DisplayManagerScreen extends StatefulWidget {
  @override
  _DisplayManagerScreenState createState() => _DisplayManagerScreenState();
}

class _DisplayManagerScreenState extends State<DisplayManagerScreen> {
  DisplayManager displayManager = DisplayManager();
  List<Display> displays = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Wrap(
              alignment: WrapAlignment.center,
              children: <Widget>[
                Button("Get Displays", () async {
                  final values = await displayManager.getDisplays();
                  print(values);
                  displays.clear();
                  displays.addAll(values);
                  print(displays);
                }),
                Button("ShowPresentation", () async {
                  final value = await displayManager.showPresentation(displayId: displays[1].displayId,routerName:"presentation");
                }),
                Button("NameByDisplayId", () async {
                  final value = await displayManager
                      .getNameByDisplayId(displays[1].displayId);
                  print(value);
                }),
                Button("NameByIndex", () async {
                  final value = await displayManager.getNameByIndex(1);
                  print(value);
                }),
                Button("TransferData", () async {
                  final value = await displayManager.transferDataToPresentation("test transfer data");
                  print(value);
                })
              ],
            ),
          ],
        ),
      ),
    );
  }
}


/// UI of Presentation
class PresentationScreen extends StatefulWidget {
  @override
  _PresentationScreenState createState() => _PresentationScreenState();
}

class _PresentationScreenState extends State<PresentationScreen> {
  String value = "init";
  @override
  Widget build(BuildContext context) {
    return PresentationDisplay(callback: (argument){
      setState(() {
        value = argument;
      });
    },child: Center(child: Text(value),),);
  }
}
92
likes
0
pub points
91%
popularity

Publisher

verified publishersmew.tech

Flutter plugin supports to run on two screens. It's basically a tablet connected to another screen via an HDMI or Wireless

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on presentation_displays