Last active
June 29, 2020 05:56
-
-
Save bluemix/fac4434e1d047ca6bc2a9023bed9dd04 to your computer and use it in GitHub Desktop.
Creating text gradient in Flutter
This file contains 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 'dart:ui' as ui; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final Shader linearGradient = LinearGradient( | |
colors: <Color>[Color(0xffDA44bb), Color(0xff8921aa)], | |
).createShader(new Rect.fromLTWH(0.0, 0.0, 200.0, 70.0)); | |
return new MaterialApp( | |
title: 'Flutter Gradient Test', | |
theme: new ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: Scaffold( | |
body: Center( | |
child: Text( | |
'Hello Gradients!', | |
style: new TextStyle( | |
fontSize: 60.0, | |
fontWeight: FontWeight.bold, | |
foreground: new Paint()..shader = linearGradient), | |
)), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment