【Flutter】Stepperの内容を受け取った文字列によって変えたい

main

class WorkStepPage extends StatefulWidget { WorkStepPage( {Key? key, required this.workname, required this.phase, required this.documentId}) : super(key: key); final String workname; final int phase; final String documentId; @override State<WorkStepPage> createState() => _WorkStepPageState(); } class _WorkStepPageState extends State<WorkStepPage> with SingleTickerProviderStateMixin { late int currentStep = int.parse(widget.phase.toString()); List<Step> cleanSteps = [ Step( isActive: true, title: Text("用具の準備"), content: Container(), ), Step( isActive: true, title: Text("濡れ拭き"), content: Container(), ), Step( isActive: true, title: Text("乾拭き"), content: Container(), ), Step( isActive: true, title: Text("ゴミ捨て"), content: Container(), ), Step( isActive: true, title: Text("用具の片付け"), content: Container(), ), ]; List<Step> programnSteps = [ Step( isActive: true, title: Text("エディター起動"), content: Container(), ), Step( isActive: true, title: Text("コーディング"), content: Container(), ), Step( isActive: true, title: Text("ビルド"), content: Container(), ), Step( isActive: true, title: Text("デバッグ"), content: Container(), ), Step( isActive: true, title: Text("リファクタリング"), content: Container(), ), ]; @override Widget build(BuildContext context) { return ChangeNotifierProvider<WorkStepModel>( create: (_) => WorkStepModel(), child: Consumer<WorkStepModel>( builder: (context, model, child) { return Scaffold( appBar: AppBar(), body: Center( child: Stepper( steps: (model.workName),     //ここを可変にしたい currentStep: currentStep, type: StepperType.vertical, // onStepTapped: (step) { // setState(() { // currentStep = step; // }); // }, onStepCancel: () { setState( () { if (currentStep > 0) { currentStep = currentStep - 1; } else { currentStep = 0; } }, ); }, onStepContinue: () { setState( () { if (currentStep < cleanSteps.length - 1) { currentStep = currentStep + 1; } else { currentStep = 0; } }, ); }, ), ), ); }, ), ); } }

コメントを投稿

0 コメント