Improve loading time/stability (at the cost of icon flickering)

This commit is contained in:
Imran Remtulla
2024-05-23 20:02:43 -04:00
parent 06a079e452
commit 7808bc5ccb
3 changed files with 66 additions and 91 deletions

View File

@@ -226,18 +226,26 @@ class _AppPageState extends State<AppPage> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 20),
app?.icon != null
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
GestureDetector(
child: Image.memory(
app!.icon!,
height: 150,
gaplessPlayback: true,
),
onTap: () => pm.openApp(app.app.id),
)
])
: Container(),
FutureBuilder(
future: app?.installedInfo?.applicationInfo?.getAppIcon(),
builder: (ctx, val) {
return val.data != null
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: app == null
? null
: () => pm.openApp(app.app.id),
child: Image.memory(
val.data!,
height: 150,
gaplessPlayback: true,
),
)
])
: Container();
}),
const SizedBox(
height: 25,
),

View File

@@ -406,31 +406,37 @@ class AppsPageState extends State<AppsPage> {
}
getAppIcon(int appIndex) {
return listedApps[appIndex].icon != null
? Image.memory(
listedApps[appIndex].icon!,
gaplessPlayback: true,
)
: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Transform(
alignment: Alignment.center,
transform: Matrix4.rotationZ(0.31),
child: Padding(
padding: const EdgeInsets.all(15),
child: Image(
image: const AssetImage(
'assets/graphics/icon_small.png'),
color: Theme.of(context).brightness == Brightness.dark
? Colors.white.withOpacity(0.4)
: Colors.white.withOpacity(0.3),
colorBlendMode: BlendMode.modulate,
gaplessPlayback: true,
),
)),
]);
return FutureBuilder(
future:
listedApps[appIndex].installedInfo?.applicationInfo?.getAppIcon(),
builder: (ctx, val) {
return val.data != null
? Image.memory(
val.data!,
gaplessPlayback: true,
)
: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Transform(
alignment: Alignment.center,
transform: Matrix4.rotationZ(0.31),
child: Padding(
padding: const EdgeInsets.all(15),
child: Image(
image: const AssetImage(
'assets/graphics/icon_small.png'),
color: Theme.of(context).brightness ==
Brightness.dark
? Colors.white.withOpacity(0.4)
: Colors.white.withOpacity(0.3),
colorBlendMode: BlendMode.modulate,
gaplessPlayback: true,
),
)),
]);
});
}
getVersionText(int appIndex) {