Flutter Presentation Display
is a Flutter plugin designed to run on multiple displays, including handling secondary (presentation) display. It provides methods to interact with connected displays, transfer data, and respond to display connection changes. Tested on SUNMI T2s.
- Retrieve a list of connected displays
- Show and hide secondary (presentation) display
- Transfer data from the main display to the secondary display or vice versa
- Listen to display connection changes
Add flutter_presentation_display
to your pubspec.yaml
file:
dependencies:
flutter:
sdk: flutter
flutter_presentation_display: any # Replace with the latest version
import 'package:flutter_presentation_display/flutter_presentation_display.dart';
Create an instance of FlutterPresentationDisplay:
final display = FlutterPresentationDisplay();
Get a list of connected displays:
List<Display>? displays = await display.getDisplays();
Get Display Name by ID Retrieve the name of a display using its ID:
String? displayName = await display.getNameByDisplayId(1);
Get Display Name by Index Retrieve the name of a display using its index in the list:
String? displayName = await display.getNameByIndex(0);
Show a secondary display with a specific ID and router name:
bool? result = await display.showSecondaryDisplay(
displayId: 1,
routerName: "presentation",
);
Hide a secondary display using its ID:
bool? result = await display.hideSecondaryDisplay(displayId: 1);
Transfer data to the secondary (presentation) display:
bool? result = await display.transferDataToPresentation({"key": "value"});
Transfer data to the main display:
bool? result = await display.transferDataToMain({"key": "value"});
Listen to changes in connected displays:
display.connectedDisplaysChangedStream.listen((int? displayId) {
print('Connected display ID: $displayId');
});
Listen for data sent from the secondary (presentation) display:
display.listenDataFromPresentationDisplay((dynamic data) {
print('Data from Presentation Display: $data');
});
Listen for data sent from the main display:
display.listenDataFromMainDisplay((dynamic data) {
print('Data from Main Display: $data');
});
Check out the example directory for a complete sample app demonstrating the use of the flutter_presentation_display
package.
This package is based on presentation_displays which is licensed under the BSD 2-Clause License.
flutter_presentation_display is a modified version of the original version.