smooth_gradient 0.1.0 copy "smooth_gradient: ^0.1.0" to clipboard
smooth_gradient: ^0.1.0 copied to clipboard

A package that allows you to create gradients that use a specific curve.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:smooth_gradient/smooth_gradient.dart';

void main() {
  runApp(
    const MaterialApp(
      title: 'Flutter Demo',
      home: _Page(),
    ),
  );
}

class _Page extends StatefulWidget {
  const _Page();

  @override
  State<_Page> createState() => _PageState();
}

class _PageState extends State<_Page> {
  Curve _curve = Curves.easeInOut;

  @override
  Widget build(BuildContext context) {
    // Black (100% opacity).
    const from = Color(0xFF000000);

    // Black (0% opacity).
    const to = Color(0x00000000);

    return Scaffold(
      appBar: AppBar(
        title: const Text('Smooth Gradient'),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Expanded(
            child: DecoratedBox(
              decoration: BoxDecoration(
                gradient: SmoothGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  curve: _curve,
                  from: from,
                  to: to,
                  steps: 8,
                ),
              ),
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(16),
            child: Center(
              child: DropdownMenu<Curve>(
                initialSelection: _curve,
                dropdownMenuEntries: const [
                  DropdownMenuEntry(
                    label: 'Curves.easeInOut',
                    value: Curves.easeInOut,
                  ),
                  DropdownMenuEntry(
                    label: 'Curves.easeIn',
                    value: Curves.easeIn,
                  ),
                  DropdownMenuEntry(
                    label: 'Curves.easeOut',
                    value: Curves.easeOut,
                  ),
                  DropdownMenuEntry(
                    label: 'Curves.linear',
                    value: Curves.linear,
                  ),
                ],
                onSelected: (value) => setState(() {
                  _curve = value!;
                }),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
17
likes
160
points
40
downloads
screenshot

Publisher

verified publishernikodembernat.com

Weekly Downloads

A package that allows you to create gradients that use a specific curve.

Homepage
Repository (GitHub)
View/report issues

Topics

#flutter #gradient #smooth #ui

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on smooth_gradient