feedback.dart 2.15 KB
Newer Older
susheel chebrolu's avatar
susheel chebrolu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
import 'package:flutter/material.dart';

class FeedbackPage extends StatefulWidget {
  static String tag = 'feedback';
  @override
  Feedback createState() => new Feedback();
}
class Feedback extends State<FeedbackPage> {
  int _currentStep = 0;
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(
            expandedHeight: 200.0,
            floating: false,
            pinned: true,
            flexibleSpace: FlexibleSpaceBar(
              title: Text('FeedBack'),
              background: Image.asset('assets/post.jpg'),
            ),
          ),
          SliverFillRemaining(
            child: Stepper(
                steps: _mySteps(),
                currentStep: this._currentStep,
                onStepTapped: (step){
                  setState(() {
                    this._currentStep = step;
                  });
                },
                onStepContinue: (){
                  setState(() {
                    if(this._currentStep < this._mySteps().length - 1){
                      this._currentStep = this._currentStep + 1;
                    }else{
                     //Logic to check if everything is completed
                      print('Completed, check fields.');
                    }
                  });
                },
                onStepCancel: () {
                  setState(() {
                    if(this._currentStep > 0){
                      this._currentStep = this._currentStep - 1;
                    }else{
                      this._currentStep = 0;
                    }
                  });
                },
              ),
            ),
          ],
        ),
      );
    }
  List<Step> _mySteps(){
    List<Step> _steps = [
      Step(
        title: Text('Step 1'),
        content: TextField(),
        isActive: _currentStep >= 0,
      ),
      Step(
        title: Text('Step 2'),
        content: TextField(),
        isActive: _currentStep >= 1,
      ),
      Step(
        title: Text('Step 3'),
        content: TextField(),
        isActive: _currentStep >= 2,
      )

    ];
    return _steps;
  }
}