dart_plex 0.0.2
dart_plex: ^0.0.2 copied to clipboard
Dart client for Plex Media Server. Supports authentication, library browsing, playlists, streaming, search and more. Targets macOS, Windows, Linux, iOS and Android.
example/dart_plex_example.dart
// Copyright © 2026 & onwards, Alessandro Di Ronza <ales.drnz@gmail.com>.
// All rights reserved.
// Use of this source code is governed by BSD 3-Clause license that can be found in the LICENSE file.
import 'package:dart_plex/dart_plex.dart';
Future<void> main() async {
final plex = PlexClient(
credentials: const PlexCredentials(
clientIdentifier: 'example-client-id',
product: 'MyApp',
version: '1.0.0',
device: 'CLI',
deviceName: 'example',
platform: 'macOS',
),
);
await plex.account.signInWithPassword(
username: 'user',
password: 'password',
);
final resources = await plex.account.fetchResources();
final server = resources.firstWhere((r) => r.owned && r.isServer);
final connection = server.bestConnection();
if (connection == null) {
print('No reachable connection for ${server.name}');
return;
}
plex.connect(connection.uri, accessToken: server.accessToken);
final sections = await plex.library.sections();
for (final s in sections) {
print('${s.title} (${s.type})');
}
}