$FILES = Get-ChildItem -Path lib, test -Recurse -Filter "*.dart" -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -notmatch '\.(g|freezed)\.dart$' } | Select-Object -ExpandProperty FullName; if (-not $FILES) { Write-Host "No Dart files found to format"; exit 0 } else { dart format --output=write --set-exit-if-changed $FILES }
32 lines
858 B
Dart
32 lines
858 B
Dart
import 'package:flutter/material.dart';
|
|
import '../models/plex_home_user.dart';
|
|
import '../i18n/strings.g.dart';
|
|
import 'provider_extensions.dart';
|
|
|
|
class UserSwitchingUtils {
|
|
static Future<bool> switchToUser(
|
|
BuildContext context,
|
|
PlexHomeUser user, {
|
|
bool popOnSuccess = false,
|
|
}) async {
|
|
final userProvider = context.userProfile;
|
|
|
|
final success = await userProvider.switchToUser(user, context);
|
|
|
|
if (success && context.mounted && popOnSuccess) {
|
|
Navigator.of(context).pop();
|
|
} else if (!success && context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
t.messages.failedToSwitchProfile(displayName: user.displayName),
|
|
),
|
|
backgroundColor: Theme.of(context).colorScheme.error,
|
|
),
|
|
);
|
|
}
|
|
|
|
return success;
|
|
}
|
|
}
|