Files
jinzhi/lib/common/widgets/circle_back_button.dart
T
2026-06-18 15:02:28 +08:00

55 lines
1.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'package:flutter_remix/flutter_remix.dart';
import 'package:go_router/go_router.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
/// 圆形返回钮(对齐 demo `.back`38×38 圆 + 1px 描边 + chevron)。
/// 左对齐到 12pxdemo `.dhead` padding-left),用作各页 AppBar 的 leading。
class CircleBackButton extends StatelessWidget {
const CircleBackButton({
super.key,
this.onTap,
this.fallbackLocation = '/assets',
});
final VoidCallback? onTap;
final String fallbackLocation;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 12),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap:
onTap ??
() {
if (context.canPop()) {
context.pop();
} else {
context.go(fallbackLocation);
}
},
child: Container(
width: 38,
height: 38,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: cs.border, width: 1),
),
child: Icon(
FlutterRemix.arrow_left_s_line,
size: 22,
color: cs.foreground,
),
),
),
),
);
}
}