Unverified Commit e989d6b1 authored by Abhishek Ghaskata's avatar Abhishek Ghaskata Committed by GitHub

Assign late variable without initstate in flutter_gallery (#83020)

parent a8ec7646
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment