Solian/lib/widgets/app_bar_leading.dart

23 lines
635 B
Dart
Raw Normal View History

import 'package:flutter/material.dart';
class AppBarLeadingButton extends StatelessWidget {
2024-10-06 17:47:34 +00:00
final bool forceBack;
2024-10-06 17:47:34 +00:00
const AppBarLeadingButton({super.key, this.forceBack = false});
static Widget? adaptive(BuildContext context, {bool forceBack = false}) {
final hasContent = Navigator.canPop(context) || forceBack;
return hasContent ? AppBarLeadingButton(forceBack: forceBack) : null;
2024-07-12 14:37:58 +00:00
}
@override
Widget build(BuildContext context) {
2024-10-06 17:47:34 +00:00
if (Navigator.canPop(context) || forceBack) {
return BackButton(
onPressed: () => Navigator.pop(context),
);
}
2024-10-06 17:47:34 +00:00
return const SizedBox.shrink();
}
}