I got this error in debug console:
Launching lib\main.dart on Chrome in debug mode... lib\main.dart:1 Error: Expected an identifier, but got ')'. lib/apilar_codigo/stacked_all.dart:20 Try inserting an identifier before ')'. StartPomodoro(end: ),
Failed to compile application. Exited (sigterm)
How can I solved it?
This is my code:
startPomodoro.dart
class StartPomodoro extends StatefulWidget {
StartPomodoro({super.key, required this.end});
final DateTime end;
@override
State<StartPomodoro> createState() => _StartPomodoroState();
}
class _StartPomodoroState extends State<StartPomodoro>
with TickerProviderStateMixin {
final now = DateTime.now();
List<bool> isSelected = [true, false];
late Timer timer;
late AnimationController controller;
String get countText {
Duration count = controller.duration! * controller.value;
return controller.isDismissed
? '${controller.duration!.inHours.toString().padLeft(2, '0')}:${(controller.duration!.inMinutes % 60).toString().padLeft(2, '0')}:${(controller.duration!.inSeconds % 60).toString().padLeft(2, '0')}'
: '${count.inHours.toString().padLeft(2, '0')}:${(count.inMinutes % 60).toString().padLeft(2, '0')}:${(count.inSeconds % 60).toString().padLeft(2, '0')}';
}
double progress = 1.0;
bool LongBreak = true;
void notify() {
if (countText == '00:00:00') {}
}
@override
void initState() {
super.initState();
controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 0),
);
controller.addListener(() {
notify();
if (controller.isAnimating) {
setState(() {
progress = controller.value;
});
} else {
setState(() {
progress = 1.0;
LongBreak = true;
});
}
});
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor:
LongBreak ? const Color(0xffD94530) : const Color(0xff6351c5),
body: SizedBox(
height: 460,
child: Stack(
children: [
Positioned(
top: 220,
left: 16,
child: GestureDetector(
onTap: () {
if (controller.isDismissed) {
showModalBottomSheet(
context: context,
builder: (context) => Container(
height: 300,
child: CupertinoTimerPicker(
initialTimerDuration: controller.duration!,
onTimerDurationChanged: (time) {
setState(() {
controller.duration = time;
});
},
),
),
);
}
},
child: AnimatedBuilder(
animation: controller,
builder: (context, child) {
return Stack(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Container(
color: const Color(0xffD94530),
height: controller.value *
MediaQuery.of(context).size.height,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: <Widget>[
Expanded(
child: Align(
alignment: Alignment.center,
child: Align(
alignment: FractionalOffset.center,
child: Container(
width: MediaQuery.of(context)
.size
.width -
64,
height: 210,
decoration: const BoxDecoration(
color: Color.fromARGB(
255, 245, 245, 245),
boxShadow: [
BoxShadow(
color: Color(0x22000000),
blurRadius: 64,
blurStyle: BlurStyle.outer,
offset: Offset(0, 16),
),
],
),
child: Container(
padding: const EdgeInsets.all(24.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
const Text(
"Hyper focused on...",
style: TextStyle(
fontSize: 22.0,
fontWeight:
FontWeight.w600,
),
),
const SizedBox(height: 16),
Center(
child: Column(
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
Text(
countText,
style:
const TextStyle(
letterSpacing:
4,
fontSize: 65.0,
color: Color(
0xff3B3B3B),
),
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment
.center,
children: const [
Text(
' Hours Minutes Seconds ',
style: TextStyle(
letterSpacing:
2,
fontSize: 20.0,
color: Color(
0xff3B3B3B),
),
),
],
),
],
),
),
],
),
),
),
),
),
),
),
],
),
),
],
);
}),
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AnimatedBuilder(
animation: controller,
builder: (context, child) {
return const Padding(
padding: EdgeInsets.symmetric(
vertical: 2.0, horizontal: 15.0),
);
}),
AnimatedBuilder(
animation: controller,
builder: (context, child) {
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 2.0, horizontal: 15.0),
child: FloatingActionButton.extended(
backgroundColor: const Color(0xffFAFAFA),
onPressed: () {
if (controller.isAnimating) {
controller.stop();
setState(() {
LongBreak = false;
});
} else {
controller.reverse(
from: controller.value == 0
? 1.0
: controller.value);
setState(() {
LongBreak = false;
});
}
},
icon: Icon(
controller.isAnimating
? Icons.pause
: Icons.play_arrow,
color: const Color(0xff3B3B3B),
),
label: Text(
controller.isAnimating ? "Pause" : "Start",
style:
const TextStyle(color: Color(0xff3B3B3B)),
)),
);
}),
],
),
),
],
),
),
),
);
}
AnimationController _buildClockAnimation(TickerProvider tickerProvider) {
return AnimationController(
vsync: tickerProvider,
duration: const Duration(milliseconds: 750),
);
}
void _animateLeftDigit(
int prev,
int current,
AnimationController controller,
) {
final prevFirstDigit = (prev / 10).floor();
final currentFirstDigit = (current / 10).floor();
if (prevFirstDigit != currentFirstDigit) {
controller.forward();
}
}
}
StackPages.dart
class StackPages extends StatelessWidget {
const StackPages({super.key});
@override
Widget build(BuildContext context) {
return Stack(
// ignore: prefer_const_literals_to_create_immutables
children: [
// ChartBar()
// PieChartSample1(),
// ToDoPage(),
StartPomodoro(end: ),
// HomePageTimerUI(),
],
);
}
}
How to get rid of this problem? I tried this but no luck:
StartPomodoro(end: end),
Thank you for any help you can offer
CodePudding user response:
Parameter
end
is of typeDateTime
.To get over this error provide value of type
DateTime
inend
parameter.Try following code:
StartPomodoro(end: DateTime.now().add(const Duration(days: 1)))