Skip to content

Instantly share code, notes, and snippets.

@liyuqian
Created January 29, 2020 14:49
Show Gist options
  • Save liyuqian/8699bf9300ed2c749b4e69710ee43ef4 to your computer and use it in GitHub Desktop.
Save liyuqian/8699bf9300ed2c749b4e69710ee43ef4 to your computer and use it in GitHub Desktop.
Sample app of CustomPaint not setting isComplex
import 'package:flutter/material.dart';
final imageUrl =
'https://cdn.vox-cdn.com/thumbor/yacVJaRnOvWiuIO3L6pe5Tmlv68=/0x26:640x453/920x613/filters:focal(0x26:640x453):format(webp)/cdn.vox-cdn.com/assets/1275052/kitten_field_jump.jpeg';
class CostlyToRasterize extends StatelessWidget {
@override
Widget build(BuildContext context) {
const color = Color(0xff00ff);
return Stack(
children: [
Image.network(imageUrl),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment(0, 0.5),
end: Alignment.bottomCenter,
colors: [color.withOpacity(0), color.withOpacity(0.9)],
),
),
),
],
);
}
}
void main() => runApp(
MaterialApp(
title: 'RootView',
showPerformanceOverlay: true,
checkerboardRasterCacheImages: true,
home: PageView.builder(
itemBuilder: (BuildContext _, int index) {
return CustomPaint(
isComplex: true,
willChange: false,
child: CostlyToRasterize(),
);
},
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment