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 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,30 +150,34 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
right: 30.0,
|
right: 30.0,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: widget.steps.first != step
|
mainAxisAlignment:
|
||||||
? MainAxisAlignment.spaceBetween
|
(widget.previousButtonBuilder != null &&
|
||||||
: MainAxisAlignment.end,
|
previousButton == null)
|
||||||
|
? MainAxisAlignment.spaceAround
|
||||||
|
: widget.steps.first != step
|
||||||
|
? MainAxisAlignment.spaceBetween
|
||||||
|
: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (widget.steps.first != step)
|
if (widget.steps.first != step)
|
||||||
widget.previousButtonBuilder?.call(
|
if (widget.previousButtonBuilder == null) ...[
|
||||||
onPrevious,
|
ElevatedButton(
|
||||||
widget.previousBtnTitle,
|
onPressed: onPrevious,
|
||||||
) ??
|
child: Row(
|
||||||
ElevatedButton(
|
children: [
|
||||||
onPressed: onPrevious,
|
const Icon(
|
||||||
child: Row(
|
Icons.arrow_back,
|
||||||
children: [
|
size: 18,
|
||||||
const Icon(
|
),
|
||||||
Icons.arrow_back,
|
Padding(
|
||||||
size: 18,
|
padding: const EdgeInsets.only(left: 4.0),
|
||||||
),
|
child: Text(widget.previousBtnTitle),
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.only(left: 4.0),
|
],
|
||||||
child: Text(widget.previousBtnTitle),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
] 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