Created
July 26, 2022 01:44
-
-
Save blendthink/e2a377d0ff1d6a28959402b91410b676 to your computer and use it in GitHub Desktop.
Gradation Demo
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 '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