29 lines
650 B
Dart
29 lines
650 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class AppBackButton extends StatelessWidget {
|
|
final String fallbackRoute;
|
|
final Color? color;
|
|
|
|
const AppBackButton({
|
|
super.key,
|
|
required this.fallbackRoute,
|
|
this.color,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return IconButton(
|
|
icon: Icon(Icons.arrow_back_ios_new_rounded, color: color),
|
|
onPressed: () {
|
|
if (context.canPop()) {
|
|
context.pop();
|
|
return;
|
|
}
|
|
context.go(fallbackRoute);
|
|
},
|
|
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
|
|
);
|
|
}
|
|
}
|