mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 05: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 AppBar? customAppBar;
|
||||||
final Color? customBackgroundColor;
|
final Color? customBackgroundColor;
|
||||||
final Widget Function(Future<void> Function(), String)? nextButtonBuilder;
|
final Widget Function(Future<void> Function(), String)? nextButtonBuilder;
|
||||||
final Widget Function(VoidCallback, String)? previousButtonBuilder;
|
final Widget? Function(VoidCallback, String)? previousButtonBuilder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AuthScreen> createState() => _AuthScreenState();
|
State<AuthScreen> createState() => _AuthScreenState();
|
||||||
|
@ -98,6 +98,11 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var previousButton = widget.previousButtonBuilder?.call(
|
||||||
|
onPrevious,
|
||||||
|
widget.previousBtnTitle,
|
||||||
|
);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: widget.customBackgroundColor ?? Colors.white,
|
backgroundColor: widget.customBackgroundColor ?? Colors.white,
|
||||||
appBar: _appBar,
|
appBar: _appBar,
|
||||||
|
@ -145,15 +150,16 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
right: 30.0,
|
right: 30.0,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: widget.steps.first != step
|
mainAxisAlignment:
|
||||||
|
(widget.previousButtonBuilder != null &&
|
||||||
|
previousButton == null)
|
||||||
|
? MainAxisAlignment.spaceAround
|
||||||
|
: widget.steps.first != step
|
||||||
? MainAxisAlignment.spaceBetween
|
? MainAxisAlignment.spaceBetween
|
||||||
: MainAxisAlignment.end,
|
: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (widget.steps.first != step)
|
if (widget.steps.first != step)
|
||||||
widget.previousButtonBuilder?.call(
|
if (widget.previousButtonBuilder == null) ...[
|
||||||
onPrevious,
|
|
||||||
widget.previousBtnTitle,
|
|
||||||
) ??
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: onPrevious,
|
onPressed: onPrevious,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
@ -169,6 +175,9 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
] else if (previousButton != null) ...[
|
||||||
|
previousButton
|
||||||
|
],
|
||||||
widget.nextButtonBuilder?.call(
|
widget.nextButtonBuilder?.call(
|
||||||
() async {
|
() async {
|
||||||
await onNext(step);
|
await onNext(step);
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RegistrationOptions {
|
||||||
final AppBar Function(String title)? customAppbarBuilder;
|
final AppBar Function(String title)? customAppbarBuilder;
|
||||||
final Widget Function(Future<void> Function() onPressed, String label)?
|
final Widget Function(Future<void> Function() onPressed, String label)?
|
||||||
nextButtonBuilder;
|
nextButtonBuilder;
|
||||||
final Widget Function(VoidCallback onPressed, String label)?
|
final Widget? Function(VoidCallback onPressed, String label)?
|
||||||
previousButtonBuilder;
|
previousButtonBuilder;
|
||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue