Skip to content

Instantly share code, notes, and snippets.

@blendthink
Created July 26, 2022 01:44
Show Gist options
  • Save blendthink/e2a377d0ff1d6a28959402b91410b676 to your computer and use it in GitHub Desktop.
Save blendthink/e2a377d0ff1d6a28959402b91410b676 to your computer and use it in GitHub Desktop.
Gradation Demo
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.blue,
brightness: Brightness.dark,
),
home: const GradationPage(),
);
}
}
class GradationPage extends StatelessWidget {
const GradationPage({
super.key,
});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Gradation Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ShaderMask(
child: const Text(
'Flutter',
style: TextStyle(
fontSize: 100,
color: Colors.white
),
),
shaderCallback: (Rect rect) {
return const LinearGradient(
colors: [
Colors.red,
Colors.orange,
Colors.yellow,
Colors.green,
Colors.blue,
Colors.indigo,
Colors.purple,
],
).createShader(rect);
},
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment