✨ Error notifier
This commit is contained in:
@@ -1,12 +1,43 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rhythm_box/platform.dart';
|
||||
import 'package:rhythm_box/providers/error_notifier.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class SystemShell extends StatelessWidget {
|
||||
class SystemShell extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const SystemShell({super.key, required this.child});
|
||||
|
||||
@override
|
||||
State<SystemShell> createState() => _SystemShellState();
|
||||
}
|
||||
|
||||
class _SystemShellState extends State<SystemShell> {
|
||||
late final ErrorNotifier _errorNotifier = Get.find();
|
||||
|
||||
StreamSubscription? _subscription;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_subscription = _errorNotifier.showing.listen((value) {
|
||||
if (value == null) {
|
||||
ScaffoldMessenger.of(context).clearMaterialBanners();
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showMaterialBanner(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_subscription?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (PlatformInfo.isMacOS) {
|
||||
@@ -21,12 +52,12 @@ class SystemShell extends StatelessWidget {
|
||||
thickness: 0.3,
|
||||
height: 0.3,
|
||||
),
|
||||
Expanded(child: child),
|
||||
Expanded(child: widget.child),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return child;
|
||||
return widget.child;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user