Reputation: 71
I can execute the sample code in demo project, but when I past the code to my project it shows:
The argument type 'Row Function(BuildContext, {void Function() onStepCancel, void Function() onStepContinue})' can't be assigned to the parameter type 'Widget Function(BuildContext, {void Function()? onStepCancel, void Function()? onStepContinue})?
if I remove the controlsBuilder:...
, the code works normally,
thanks.
import 'package:flutter/material.dart';
class StepperDemo extends StatefulWidget {
@override
_StepperDemoState createState() => _StepperDemoState();
}
class _StepperDemoState extends State<StepperDemo> {
int _currentStep = 0;
StepperType stepperType = StepperType.vertical;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text('Flutter Stepper Demo'),
centerTitle: true,
),
body: Container(
child: Column(
children: [
Expanded(
child: Stepper(
controlsBuilder: (BuildContext context, {VoidCallback onStepContinue, VoidCallback onStepCancel}) {
return Row(
children: <Widget>[
TextButton(
onPressed: onStepContinue,
child: const Text('下一步'),
),
TextButton(
onPressed: onStepCancel,
child: const Text('離開'),
),
],
);
},
Upvotes: 6
Views: 5188
Reputation: 857
New documentation suggests that you do use ControlDetails details
controlsBuilder: (BuildContext context, ControlsDetails details){}
Upvotes: 0
Reputation: 261
Prior to Flutter 2.6.0, the controlsBuilder returns two callbacks: onStepContinue and onStepCancel. These callbacks are now replaced with a single ControlsDetails object.
You can rewrite your Stepper constructor as follow
child: Stepper(
controlsBuilder: (BuildContext context, ControlsDetails controls) {
return Row(
children: <Widget>[
TextButton(
onPressed: controls.onStepContinue,
child: const Text('下一步'),
),
TextButton(
onPressed: controls.onStepCancel,
child: const Text('離開'),
),
],
);
},
Upvotes: 24