Skip to content

Instantly share code, notes, and snippets.

@bluemix
Last active June 29, 2020 05:56
Show Gist options
  • Save bluemix/fac4434e1d047ca6bc2a9023bed9dd04 to your computer and use it in GitHub Desktop.
Save bluemix/fac4434e1d047ca6bc2a9023bed9dd04 to your computer and use it in GitHub Desktop.
Creating text gradient in Flutter
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