Created
January 29, 2020 14:49
-
-
Save liyuqian/8699bf9300ed2c749b4e69710ee43ef4 to your computer and use it in GitHub Desktop.
Sample app of CustomPaint not setting isComplex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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