我正在使用time_range flutter包,并希望为每个日期使用开始和结束时间。在第一次点击它是工作正常,但当我试图更改日期,以前选择的开始和结束时间仍然选择。
import 'package:time_range/time_range.dart';
var initialRangeOpeningHours = TimeRangeResult(
TimeOfDay(hour: 09, minute: 00),
TimeOfDay(hour: 23, minute: 59),
Container(
width: MediaQuery.of(context).size.width,
child: TimeRange(
initialRange: initialRangeOpeningHours,
fromTitle: Text(
'Start Time',
style: TextStyle(
fontSize: 13, color: Colors.grey),
),
toTitle: Text(
'End Time',
style: TextStyle(
fontSize: 13, color: Colors.grey),
),
titlePadding: 20,
textStyle: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black87),
activeTextStyle: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white),
borderColor: Colors.black,
backgroundColor: Color(0xFFF5F5F5),
activeBackgroundColor: forIos
? BaseAppTheme.of(context).gray200 //
: BaseAppTheme.of(context)
.stepsBackground, //
firstTime: TimeOfDay(hour: 0, minute: 00),
lastTime: TimeOfDay(hour: 23, minute: 59),
timeStep: 60,
timeBlock: 60,
onFirstTimeSelected: (hour) {
setState(() {
forIos = false;
});
},
onRangeCompleted: (range) {
if (range != null) {
print('dnkjfnewkf: ${range.end.hour}');
print(
'ndjkwbfkqw: ${range.start.hour}');
setState(() {
forIos = false;
timingAddedForSelectedDates
.add(selectedDate);
});
}
}));
这工作正常,但我想重置此计时器到其初始状态,没有任何先前选择的开始和结束时间?
1条答案
按热度按时间gkl3eglg1#
修改下面的代码,看看是否有效