Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class GradientPractice extends StatefulWidget {
  4. _GradientPractice createState() => _GradientPractice();
  5. }
  6.  
  7. class _GradientPractice extends State<GradientPractice> {
  8. List<Color> _colors = [Colors.deepOrange, Colors.yellow];
  9. List<double> _stops = [0.0, 0.7];
  10.  
  11. @override
  12. void initState() {
  13. super.initState();
  14. }
  15.  
  16. @override
  17. Widget build(BuildContext context) {
  18. return MaterialApp(
  19. home: Column(
  20. children: [
  21. SizedBox(
  22. height: 40,
  23. ),
  24. Container(
  25. height: 100,
  26. width: 100,
  27. decoration: BoxDecoration(
  28. gradient: LinearGradient(
  29. colors: _colors,
  30. stops: _stops,
  31. )),
  32. ),
  33. infoText("LinearGradient"),
  34. Container(
  35. height: 100,
  36. width: 100,
  37. decoration: BoxDecoration(
  38. gradient: RadialGradient(
  39. colors: _colors,
  40. stops: _stops,
  41. ),),
  42. ),
  43. infoText("RadialGradient"),
  44. Container(
  45. height: 100,
  46. width: 100,
  47. decoration: BoxDecoration(
  48. gradient: SweepGradient(
  49. colors: _colors,
  50. stops: _stops,
  51. )),
  52. ),
  53. infoText("SweepGradient"),
  54. ],
  55. ),
  56. );
  57. }
  58.  
  59. Widget infoText(String s) {
  60. return Padding(
  61. padding: const EdgeInsets.all(18.0),
  62. child: Text(
  63. s,
  64. textAlign: TextAlign.center,
  65. style: TextStyle(
  66. fontSize: 18,
  67. color: Colors.white,
  68. decoration: TextDecoration.none,
  69. ),
  70. ),
  71. );
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement