anadea_stepper 0.0.3 copy "anadea_stepper: ^0.0.3" to clipboard
anadea_stepper: ^0.0.3 copied to clipboard

Anadea stepper. Сorrected version of the stock Material Stepper in Flutter. Stepper is a widget that displays progress through a sequence of steps. Steppers are particularly useful in the case of form [...]

example/lib/main.dart

import 'package:anadea_stepper/anadea_stepper.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  static const String _title = 'Anadea Stepper Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: const Center(
          child: MyStatefulWidget(),
        ),
      ),
    );
  }
}

class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({super.key});

  @override
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  int _currentStep = 0;
  int stepperSize = 7;
  AStepperType stepperType = AStepperType.horizontal;

  @override
  Widget build(BuildContext context) {
    return AStepper(
      type: stepperType,
      physics: const ClampingScrollPhysics(),
      currentStep: _currentStep,
      onStepTapped: (step) => tapped(step),
      onStepContinue: continued,
      onStepCancel: cancel,
      steps: <AStep>[
        AStep(
          title: const Text('Step 1'),
          content: Column(
            children: <Widget>[
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 1'),
              ),
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 1'),
              ),
            ],
          ),
          isActive: _currentStep >= 0,
          state: _currentStep >= 0
              ? AStepState.complete
              : AStepState.disabled,
        ),
        AStep(
          title: const Text('Step 2'),
          content: Column(
            children: <Widget>[
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 2'),
              ),
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 2'),
              ),
            ],
          ),
          isActive: _currentStep >= 0,
          state: _currentStep >= 1
              ? AStepState.complete
              : AStepState.disabled,
        ),
        AStep(
          title: const Text('Step 3'),
          content: Column(
            children: <Widget>[
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 3'),
              ),
            ],
          ),
          isActive: _currentStep >= 0,
          state: _currentStep >= 2
              ? AStepState.complete
              : AStepState.disabled,
        ),
        AStep(
          title: const Text('Step 4'),
          content: Column(
            children: <Widget>[
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 4'),
              ),
            ],
          ),
          isActive: _currentStep >= 0,
          state: _currentStep >= 3
              ? AStepState.complete
              : AStepState.disabled,
        ),
        AStep(
          title: const Text('Step 5'),
          content: Column(
            children: <Widget>[
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 5'),
              ),
            ],
          ),
          isActive: _currentStep >= 0,
          state: _currentStep >= 4
              ? AStepState.complete
              : AStepState.disabled,
        ),
        AStep(
          title: const Text('Step 6'),
          content: Column(
            children: <Widget>[
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 6'),
              ),
            ],
          ),
          isActive: _currentStep >= 0,
          state: _currentStep >= 5
              ? AStepState.complete
              : AStepState.disabled,
        ),
        AStep(
          title: const Text('Step 7'),
          content: Column(
            children: <Widget>[
              TextFormField(
                decoration:
                const InputDecoration(labelText: 'TextFormField 7'),
              ),
            ],
          ),
          isActive: _currentStep >= 0,
          state: _currentStep >= 6
              ? AStepState.complete
              : AStepState.disabled,
        ),
      ],
    );
  }

  switchStepsType() {
    setState(() => stepperType == AStepperType.vertical
        ? stepperType = AStepperType.horizontal
        : stepperType = AStepperType.vertical);
  }

  tapped(int step) {
    setState(() => _currentStep = step);
  }

  continued() {
    _currentStep < stepperSize - 1 ? setState(() => _currentStep += 1) : null;
  }

  cancel() {
    _currentStep > 0 ? setState(() => _currentStep -= 1) : null;
  }
}
8
likes
0
pub points
65%
popularity

Publisher

verified publisheranadeainc.com

Anadea stepper. Сorrected version of the stock Material Stepper in Flutter. Stepper is a widget that displays progress through a sequence of steps. Steppers are particularly useful in the case of forms where one step requires the completion of another one, or where multiple steps need to be completed in order to submit the whole form.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on anadea_stepper