Flutter Dart constructeur

Dans le flottement de la page d'Exemples, il y a un projet intitulé "Envoi de Données à un nouvel écran". J'ai une question concernant le constructeur sur la ligne 65.

Envoi de Données à un nouvel écran

  //In the constructor, require a Todo
  DetailScreen({Key key, @required this.todo}) : super(key: key);

Qu'est-ce que le super(key: la clé)? Pourrais-je obtenir une explication de l'ensemble de la ligne s'il vous plaît. Le Code est ici....

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
class Todo {
final String title;
final String description;
Todo(this.title, this.description);
}
void main() {
runApp(MaterialApp(
title: 'Passing Data',
home: TodosScreen(
todos: List.generate(
20,
(i) => Todo(
'Todo $i',
'A description of what needs to be done for Todo $i',
),
),
),
));
}
class TodosScreen extends StatelessWidget {
final List<Todo> todos;
TodosScreen({Key key, @required this.todos}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Todos'),
),
body: ListView.builder(
itemCount: todos.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(todos[index].title),
//When a user taps on the ListTile, navigate to the DetailScreen.
//Notice that we're not only creating a DetailScreen, we're
//also passing the current todo through to it!
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailScreen(todo: todos[index]),
),
);
},
);
},
),
);
}
}
class DetailScreen extends StatelessWidget {
//Declare a field that holds the Todo
final Todo todo;
//In the constructor, require a Todo
DetailScreen({Key key, @required this.todo}) : super(key: key);
@override
Widget build(BuildContext context) {
//Use the Todo to create our UI
return Scaffold(
appBar: AppBar(
title: Text("${todo.title}"),
),
body: Padding(
padding: EdgeInsets.all(16.0),
child: Text('${todo.description}'),
),
);
}
}
InformationsquelleAutor IrishGringo | 2018-06-24