Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- class GradientPractice extends StatefulWidget {
- _GradientPractice createState() => _GradientPractice();
- }
- class _GradientPractice extends State<GradientPractice> {
- List<Color> _colors = [Colors.deepOrange, Colors.yellow];
- List<double> _stops = [0.0, 0.7];
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Column(
- children: [
- SizedBox(
- height: 40,
- ),
- Container(
- height: 100,
- width: 100,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: _colors,
- stops: _stops,
- )),
- ),
- infoText("LinearGradient"),
- Container(
- height: 100,
- width: 100,
- decoration: BoxDecoration(
- gradient: RadialGradient(
- colors: _colors,
- stops: _stops,
- ),),
- ),
- infoText("RadialGradient"),
- Container(
- height: 100,
- width: 100,
- decoration: BoxDecoration(
- gradient: SweepGradient(
- colors: _colors,
- stops: _stops,
- )),
- ),
- infoText("SweepGradient"),
- ],
- ),
- );
- }
- Widget infoText(String s) {
- return Padding(
- padding: const EdgeInsets.all(18.0),
- child: Text(
- s,
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 18,
- color: Colors.white,
- decoration: TextDecoration.none,
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement