Steeper的水平视图如何?

时间:2019-07-19 12:48:46

标签: flutter

这是我的小部件

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

    class MyStepper extends StatefulWidget {   @override  
    _MyStepperState createState() => _MyStepperState(); }

    class _MyStepperState extends State<MyStepper> {   int CurrentStep =
    0;   int step;   var SetState;   VoidCallback mContinue;  
    VoidCallback mCancel;   ScrollController scrollController = new
    ScrollController();

      @override   Widget build(BuildContext context) {
        List<Step> my_steps = [
          new Step(
              title: Padding(
                padding: EdgeInsets.only(right: 10.0),
                child: new Text('First step'),
              ),
              content: new Text('this is the  first step.'),
              isActive: (CurrentStep >= 0),
              state: (CurrentStep == 0) ? StepState.complete : StepState.disabled),
          new Step(
            title: Padding(
              padding: EdgeInsets.only(right: 10.0),
              child: new Text('Second step'),
            ),
            content: Text('this is the second step'),
            isActive: (CurrentStep >= 0),
            state: (CurrentStep == 1) ? StepState.complete : StepState.disabled,
          ),
          new Step(
            title: Padding(
              padding: EdgeInsets.only(right: 10.0),
              child: new Text('Third step'),
            ),
            content: new Text('this is third step'),
            isActive: (CurrentStep >= 0),
            state: (CurrentStep == 2) ? StepState.complete : StepState.disabled,
          ),
          new Step(
            title: Padding(
              padding: EdgeInsets.only(right: 10.0),
              child: new Text('Third step'),
            ),
            content: new Text('this is third step'),
            isActive: (CurrentStep >= 0),
            state: (CurrentStep == 3) ? StepState.complete : StepState.disabled,
          ),
          new Step(
            title: new Text('Third step'),
            content: new Text('this is third step'),
            isActive: (CurrentStep >= 0),
            state: (CurrentStep == 4) ? StepState.complete : StepState.disabled,
          ),
        ];
        return Scaffold(
          resizeToAvoidBottomPadding: false,
          appBar: AppBar(
            title: Text('Load Provider'),
            centerTitle: true,
          ),
          body: NestedScrollView(
            controller: scrollController,
            headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
              return <Widget>[
                SliverList(
                  delegate: SliverChildListDelegate(<Widget>[
                    Container(),
                  ]),
                ),
              ];
            },
            body: Stepper(
                type: StepperType.horizontal,
                physics: AlwaysScrollableScrollPhysics(),
                onStepContinue: () {
                  setState(() {
                    if (CurrentStep < my_steps.length - 1) {
                      CurrentStep = CurrentStep + 1;
                    } else {
                      CurrentStep = 0;
                    }
                  });
                },
                onStepCancel: () {
                  setState(() {
                    if (CurrentStep > 0) {
                      CurrentStep = CurrentStep - 1;
                    } else {
                      CurrentStep = 0;
                    }
                  });
                },
                currentStep: this.CurrentStep,
                onStepTapped: (step) {
                  setState(() {
                    CurrentStep = step;
                  });
                },
                steps: my_steps,
                controlsBuilder: (BuildContext context,
                    {VoidCallback onStepContinue, VoidCallback onStepCancel}) {
                  mContinue = onStepContinue;
                  mCancel = onStepCancel;
                  return Container();
                }),
          ),
          bottomNavigationBar: new Container(
            margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
            color: Colors.blue,
            child: new ConstrainedBox(
              constraints: const BoxConstraints.tightFor(height: 48.0),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  new FlatButton(
                    onPressed: () {
                      return mCancel();
                    },
                    textColor: Colors.white,
                    textTheme: ButtonTextTheme.normal,
                    child: new Row(children: <Widget>[
                      const Icon(Icons.chevron_left),
                      const Text('BACK')
                    ]),
                  ),
                  new FlatButton(
                    onPressed: () {
                      return mContinue();
                    },
                    textColor: Colors.white,
                    textTheme: ButtonTextTheme.normal,
                    child: new Row(children: const <Widget>[
                      const Text('NEXT'),
                      const Icon(Icons.chevron_right)
                    ]),
                  )
                ],
              ),
            ),
          ),
        );   } }

这是问题所在: enter image description here

0 个答案:

没有答案