I've used PageView.Builder() to build widgets fed from an array of basic text Widgets. But in debug mode the animation feels very laggy. In release or profiling mode the animation is still laggy but lot less. Is there any way to completely smooth out the animation lagginess when PageView is used.
Here's my code,
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: pageView(),
);
}
}
class pageView extends StatelessWidget {
var color = [
Colors.white,
Colors.lightBlue,
Colors.lightGreen,
Colors.limeAccent
];
PageController controller = PageController();
@override
Widget build(BuildContext context) {
return PageView.builder(
itemCount: 5,
controller: PageController(initialPage: 1),
itemBuilder: (BuildContext context, int itemIndex) {
return pageProvider(color[itemIndex]);
},
);
}
}
class pageProvider extends StatelessWidget {
Color color;
pageProvider(this.color);
Text fillText() {
var str = "";
for (int i = 0; i < 1000; i++) {
str += (" " + 'allan $i');
if (i % 10 == 0) {
str += '\n';
}
}
return Text(str);
}
Widget build(BuildContext context) {
return Container(color: color, child: fillText());
}
}
Here's the link of my profiling graph. I've done this profiling on a android mobile with 6 gb ram and snapdragon 636 with some Nice gpu. Link: https://drive.google.com/file/d/1khbhKQttVXbdHf0_z1b1iPA11BDOcmdW/view?usp=sharing