For what are using angle brackets <>
in class inheritance declaration in Dart language?
Code example from Flutter's project code:
class _HomeState extends State<Home> {
...
}
The code tells that class _HomeState
extends class State
, but for what is <Home>
?
Official docs says that State<T extends StatefulWidget>
class is The logic and internal state for a StatefulWidget .
so in your case we will have:
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Container();
}
}
Official documentation: State Class StatefulWidget Class
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.