Skip to content

Commit

Permalink
RSM Prototype #3 PageView Test #2
Browse files Browse the repository at this point in the history
- Const vs non const test.
  • Loading branch information
rayliverified committed Dec 1, 2023
1 parent 68066c1 commit 1b1da23
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/main_pageview_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class MyAppState extends State<MyApp> {
physics: AlwaysScrollableScrollPhysics(),
controller: PageController(viewportFraction: 0.8),
children: [
CounterPage(),
CounterPage(),
CounterPage(), // Add as many pages as you want
for (int i = 0; i < 10; i++) CounterPage(),
],
),
),
Expand All @@ -44,11 +42,14 @@ class MyAppState extends State<MyApp> {
}

class CounterPage extends StatefulWidget {
CounterPage({Key? key}) : super(key: key);

@override
_CounterPageState createState() => _CounterPageState();
}

class _CounterPageState extends State<CounterPage> {
class _CounterPageState extends State<CounterPage>
with AutomaticKeepAliveClientMixin {
int _counter = 0;

void _incrementCounter() {
Expand Down Expand Up @@ -91,4 +92,7 @@ class _CounterPageState extends State<CounterPage> {
),
);
}

@override
bool get wantKeepAlive => true;
}

0 comments on commit 1b1da23

Please sign in to comment.