Na classe esta dando esse erro, eu substitui {super.key} por {Key? key}, mesmo assim o problema persiste.
class Task extends StatelessWidget { final String nome; const Task(this.nome,{super.key});
38:9: Context: Found this candidate, but the arguments don't match. const Task(this.nome,{super.key}); ^^^^
Código completo:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: Scaffold(
appBar: AppBar(
title: Text('Tarefas'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Task(),
Task(),
Task(),
],
),
floatingActionButton: FloatingActionButton(onPressed: (){}),
),
);
}
}
class Task extends StatelessWidget {
final String nome;
const Task(this.nome,{Key? key});
@override
Widget build(BuildContext context) => Container(
child: Stack(
children: [
Container(
color: Colors.blue,
height: 140,
),
Container(
color: Colors.white,
height: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
color: Colors.black26,
width: 72,
height: 100,
),
Text(nome),
ElevatedButton(
onPressed: () {}, child: Icon(Icons.arrow_drop_up)),
],
),
),
],
));
}