Skip to content

Instantly share code, notes, and snippets.

@omegasoft7
Last active September 16, 2024 12:46
Show Gist options
  • Save omegasoft7/18a1d17205f1edfbc45d342613fcbd66 to your computer and use it in GitHub Desktop.
Save omegasoft7/18a1d17205f1edfbc45d342613fcbd66 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List<String> items = List.generate(10000, (index) => 'Item $index');
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Performance Test'),
),
body: ListView.builder(
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(
title: Hero(
tag: "hero_key_$index",
child: Text(
items[index],
),
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
DetailPage(item: items[index], index: index),
),
);
},
);
},
),
);
}
}
class DetailPage extends StatelessWidget {
final String item;
final int index;
DetailPage({required this.item, required this.index});
@override
Widget build(BuildContext context) {
_heavyCalculation();
return Scaffold(
appBar: AppBar(
title: Hero(
tag: "hero_key_$index",
child: Text(
item,
style: TextStyle(
fontSize: 16.0, // Set the desired font size
color: Colors.black, // Set the desired text color
),
),
),
),
body: Center(
child: Text('Detail of $item'),
),
);
}
// Simulate a heavy computation
_heavyCalculation() {
for (int i = 0; i < 1000000000; i++) {
// print("progressing... i:$i");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment