mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-18 21:23:43 +02:00
feat(buttons): Added the possiblity to only have a next button by return zero on the previous button builder
This commit is contained in:
parent
5bc388677b
commit
d1ad003c22
2 changed files with 32 additions and 23 deletions
|
@ -34,7 +34,7 @@ class AuthScreen extends StatefulWidget {
|
|||
final AppBar? customAppBar;
|
||||
final Color? customBackgroundColor;
|
||||
final Widget Function(Future<void> Function(), String)? nextButtonBuilder;
|
||||
final Widget Function(VoidCallback, String)? previousButtonBuilder;
|
||||
final Widget? Function(VoidCallback, String)? previousButtonBuilder;
|
||||
|
||||
@override
|
||||
State<AuthScreen> createState() => _AuthScreenState();
|
||||
|
@ -98,6 +98,11 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var previousButton = widget.previousButtonBuilder?.call(
|
||||
onPrevious,
|
||||
widget.previousBtnTitle,
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: widget.customBackgroundColor ?? Colors.white,
|
||||
appBar: _appBar,
|
||||
|
@ -145,30 +150,34 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
right: 30.0,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: widget.steps.first != step
|
||||
? MainAxisAlignment.spaceBetween
|
||||
: MainAxisAlignment.end,
|
||||
mainAxisAlignment:
|
||||
(widget.previousButtonBuilder != null &&
|
||||
previousButton == null)
|
||||
? MainAxisAlignment.spaceAround
|
||||
: widget.steps.first != step
|
||||
? MainAxisAlignment.spaceBetween
|
||||
: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (widget.steps.first != step)
|
||||
widget.previousButtonBuilder?.call(
|
||||
onPrevious,
|
||||
widget.previousBtnTitle,
|
||||
) ??
|
||||
ElevatedButton(
|
||||
onPressed: onPrevious,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.arrow_back,
|
||||
size: 18,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: Text(widget.previousBtnTitle),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.previousButtonBuilder == null) ...[
|
||||
ElevatedButton(
|
||||
onPressed: onPrevious,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.arrow_back,
|
||||
size: 18,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: Text(widget.previousBtnTitle),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
] else if (previousButton != null) ...[
|
||||
previousButton
|
||||
],
|
||||
widget.nextButtonBuilder?.call(
|
||||
() async {
|
||||
await onNext(step);
|
||||
|
|
|
@ -28,7 +28,7 @@ class RegistrationOptions {
|
|||
final AppBar Function(String title)? customAppbarBuilder;
|
||||
final Widget Function(Future<void> Function() onPressed, String label)?
|
||||
nextButtonBuilder;
|
||||
final Widget Function(VoidCallback onPressed, String label)?
|
||||
final Widget? Function(VoidCallback onPressed, String label)?
|
||||
previousButtonBuilder;
|
||||
final Color? backgroundColor;
|
||||
|
||||
|
|
Loading…
Reference in a new issue