Skip to content

Instantly share code, notes, and snippets.

@Senhordim
Forked from mjohnsullivan/icon_gradient.dart
Last active March 25, 2020 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Senhordim/2f2e29cbe4762927a5908c4521f973ef to your computer and use it in GitHub Desktop.
Save Senhordim/2f2e29cbe4762927a5908c4521f973ef to your computer and use it in GitHub Desktop.
Aplicar gradiente em um Icon no Futter
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: RadiantGradientMask(
child: Icon(
Icons.book,
size: 250,
color: Colors.white,
),
),
),
),
);
}
}
class RadiantGradientMask extends StatelessWidget {
RadiantGradientMask({this.child});
final Widget child;
@override
Widget build(BuildContext context) {
return ShaderMask(
shaderCallback: (bounds) => RadialGradient(
center: Alignment.center,
radius: 0.5,
colors: [Colors.blue, Colors.red],
tileMode: TileMode.mirror,
).createShader(bounds),
child: child,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment