mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
Assign late variable without initstate in flutter_gallery (#83020)
This commit is contained in:
parent
a8ec764609
commit
e989d6b1fa
|
@ -302,21 +302,15 @@ class Tab1ItemPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
relatedColors = List<Color>.generate(10, (int index) {
|
||||
final math.Random random = math.Random(widget.randomSeed);
|
||||
return Color.fromARGB(
|
||||
255,
|
||||
(widget.color!.red + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color!.green + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color!.blue + random.nextInt(100) - 50).clamp(0, 255),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
late List<Color> relatedColors;
|
||||
late final List<Color> relatedColors = List<Color>.generate(10, (int index) {
|
||||
final math.Random random = math.Random(widget.randomSeed);
|
||||
return Color.fromARGB(
|
||||
255,
|
||||
(widget.color!.red + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color!.green + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color!.blue + random.nextInt(100) - 50).clamp(0, 255),
|
||||
);
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class GalleryApp extends StatefulWidget {
|
|||
class _GalleryAppState extends State<GalleryApp> {
|
||||
GalleryOptions? _options;
|
||||
Timer? _timeDilationTimer;
|
||||
late AppStateModel model;
|
||||
late final AppStateModel model = AppStateModel()..loadProducts();
|
||||
|
||||
Map<String, WidgetBuilder> _buildRoutes() {
|
||||
// For a different example of how to set up an application routing table
|
||||
|
@ -66,7 +66,6 @@ class _GalleryAppState extends State<GalleryApp> {
|
|||
timeDilation: timeDilation,
|
||||
platform: defaultTargetPlatform,
|
||||
);
|
||||
model = AppStateModel()..loadProducts();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue