@@ -1956,7 +1956,7 @@ steps:
19561956 patch-u : |
19571957 --- b/intro_flutter_gpu/step_12/lib/main.dart
19581958 +++ a/intro_flutter_gpu/step_12/lib/main.dart
1959- @@ -3,14 +3,11 @@
1959+ @@ -3,20 +3,21 @@
19601960 // found in the LICENSE file.
19611961
19621962 import 'dart:math' as math;
@@ -1970,17 +1970,29 @@ steps:
19701970 -import 'shaders.dart';
19711971 -
19721972 void main() {
1973- runApp(const MainApp());
1973+ - runApp(const MainApp());
1974+ + runApp(
1975+ + MainApp(staticResourcesInitialized: scn.Scene.initializeStaticResources()),
1976+ + );
19741977 }
1975- @@ -25,6 +22,7 @@ class MainApp extends StatefulWidget {
1978+
1979+ class MainApp extends StatefulWidget {
1980+ - const MainApp({super.key});
1981+ + const MainApp({super.key, required this.staticResourcesInitialized});
1982+ +
1983+ + final Future<void> staticResourcesInitialized;
1984+
1985+ @override
1986+ State<MainApp> createState() => _MainAppState();
1987+ @@ -25,6 +26,7 @@ class MainApp extends StatefulWidget {
19761988 class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
19771989 late AnimationController _controller;
19781990 late Animation<double> _animation;
19791991 + final scene = scn.Scene();
19801992
19811993 @override
19821994 void initState() {
1983- @@ -35,6 +33 ,11 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
1995+ @@ -35,6 +37 ,11 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
19841996 )..repeat();
19851997
19861998 _animation = Tween<double>(begin: 0, end: 4 * math.pi).animate(_controller);
@@ -1992,7 +2004,7 @@ steps:
19922004 }
19932005
19942006 @override
1995- @@ -46,14 +49,24 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
2007+ @@ -46,17 +53,35 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
19962008 @override
19972009 Widget build(BuildContext context) {
19982010 return MaterialApp(
@@ -2001,25 +2013,40 @@ steps:
20012013 debugShowCheckedModeBanner: false,
20022014 home: Scaffold(
20032015 body: SizedBox.expand(
2004- child: AnimatedBuilder(
2005- builder: (context, child) {
2006- return CustomPaint(
2016+ - child: AnimatedBuilder(
2017+ - builder: (context, child) {
2018+ - return CustomPaint(
20072019 - painter: TrianglePainter(angle: _animation.value),
2008- + painter: ScenePainter(
2009- + scene: scene,
2010- + camera: scn.PerspectiveCamera(
2011- + position: vm.Vector3(
2012- + math.sin(_animation.value) * 3,
2013- + 2,
2014- + math.cos(_animation.value) * 3,
2020+ + child: FutureBuilder(
2021+ + future: widget.staticResourcesInitialized,
2022+ + builder: (context, snapshot) {
2023+ + if (snapshot.connectionState != ConnectionState.done) {
2024+ + return const Center(child: CircularProgressIndicator());
2025+ + }
2026+ + return AnimatedBuilder(
2027+ + builder: (context, child) {
2028+ + return CustomPaint(
2029+ + painter: ScenePainter(
2030+ + scene: scene,
2031+ + camera: scn.PerspectiveCamera(
2032+ + position: vm.Vector3(
2033+ + math.sin(_animation.value) * 3,
2034+ + 2,
2035+ + math.cos(_animation.value) * 3,
2036+ + ),
2037+ + target: vm.Vector3(0, 0, 0),
2038+ + ),
20152039 + ),
2016- + target: vm.Vector3(0, 0, 0),
2017- + ) ,
2018- + ) ,
2040+ + );
2041+ + } ,
2042+ + animation: _animation ,
20192043 );
20202044 },
2021- animation: _animation,
2022- @@ -64,151 +77,14 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
2045+ - animation: _animation,
2046+ ),
2047+ ),
2048+ ),
2049+ @@ -64,151 +89,14 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
20232050 }
20242051 }
20252052
@@ -2176,6 +2203,29 @@ steps:
21762203 }
21772204
21782205 @override
2206+ - name : Patch text/widget_test.dart
2207+ path : intro_flutter_gpu/test/widget_test.dart
2208+ patch-u : |
2209+ --- b/intro_flutter_gpu/step_12/test/widget_test.dart
2210+ +++ a/intro_flutter_gpu/step_12/test/widget_test.dart
2211+ @@ -2,6 +2,7 @@
2212+ // Use of this source code is governed by a BSD-style license that can be
2213+ // found in the LICENSE file.
2214+
2215+ +import 'package:flutter_scene/scene.dart';
2216+ import 'package:flutter_test/flutter_test.dart';
2217+
2218+ import 'package:intro_flutter_gpu/main.dart';
2219+ @@ -9,6 +10,8 @@ import 'package:intro_flutter_gpu/main.dart';
2220+ void main() {
2221+ testWidgets('smoke test', (tester) async {
2222+ // Build our app and trigger a frame.
2223+ - await tester.pumpWidget(const MainApp());
2224+ + await tester.pumpWidget(
2225+ + MainApp(staticResourcesInitialized: Scene.initializeStaticResources()),
2226+ + );
2227+ });
2228+ }
21792229 - name : Copy step_12
21802230 copydir :
21812231 from : intro_flutter_gpu
0 commit comments