fancy_border 0.0.2 copy "fancy_border: ^0.0.2" to clipboard
fancy_border: ^0.0.2 copied to clipboard

Seamlessly integrates with existing Flutter shape borders. Configurable the underlying shape while adding the desired gradient or pattern effect.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:fancy_border/fancy_border.dart';
import 'package:wx_text/wx_text.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Fancy Border Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const WxText.displayLarge(
              'FancyBorder',
              fontWeight: FontWeight.bold,
              outlineColor: Colors.white,
              outlineWidth: .5,
              shadows: [
                Shadow(
                  color: Colors.green,
                  blurRadius: 3,
                ),
              ],
              gradient: LinearGradient(
                colors: [
                  Colors.green,
                  Colors.blue,
                ],
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
              ),
            ),
            const SizedBox(height: 45),
            Wrap(
              spacing: 30,
              children: [
                Container(
                  width: 100,
                  height: 50,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: RoundedRectangleBorder(),
                      style: FancyBorderStyle.solid,
                      width: 4,
                      offset: 2,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.all(Radius.circular(10)),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Rounded'),
                ),
                Container(
                  width: 100,
                  height: 50,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: ContinuousRectangleBorder(),
                      style: FancyBorderStyle.solid,
                      width: 4,
                      offset: 2,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.all(Radius.circular(40)),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Continuous'),
                ),
              ],
            ),
            const SizedBox(height: 30),
            Wrap(
              spacing: 30,
              children: [
                Container(
                  width: 100,
                  height: 50,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: BeveledRectangleBorder(),
                      style: FancyBorderStyle.dashed,
                      width: 4,
                      offset: 2,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.all(Radius.circular(10)),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Beveled'),
                ),
                Container(
                  width: 100,
                  height: 50,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: StadiumBorder(),
                      style: FancyBorderStyle.dashed,
                      width: 4,
                      offset: 2,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.all(Radius.circular(10)),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Stadium'),
                ),
              ],
            ),
            const SizedBox(height: 30),
            Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              spacing: 30,
              children: [
                Container(
                  width: 60,
                  height: 60,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: CircleBorder(),
                      style: FancyBorderStyle.dotted,
                      width: 5,
                      offset: 2,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.all(Radius.circular(10)),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Circle'),
                ),
                Container(
                  width: 100,
                  height: 50,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: OvalBorder(),
                      style: FancyBorderStyle.dotted,
                      width: 5,
                      offset: 2,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.all(Radius.circular(10)),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Oval'),
                ),
              ],
            ),
            const SizedBox(height: 30),
            Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              spacing: 30,
              children: [
                Container(
                  width: 90,
                  height: 90,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: StarBorder(innerRadiusRatio: .6),
                      style: FancyBorderStyle.morse,
                      width: 3,
                      offset: 5,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.all(Radius.circular(10)),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Star'),
                ),
                Container(
                  width: 100,
                  height: 60,
                  decoration: const ShapeDecoration(
                    color: Colors.yellow,
                    shape: FancyBorder(
                      shape: RoundedRectangleBorder(),
                      style: FancyBorderStyle.morse,
                      width: 3,
                      offset: 3,
                      gradient:
                          LinearGradient(colors: [Colors.blue, Colors.red]),
                      corners: BorderRadius.only(
                        topLeft: Radius.circular(35),
                        bottomRight: Radius.circular(35),
                      ),
                    ),
                  ),
                  alignment: Alignment.center,
                  child: const Text('Leaf'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
3
likes
160
points
128
downloads

Publisher

verified publisherwidgetarian.com

Weekly Downloads

Seamlessly integrates with existing Flutter shape borders. Configurable the underlying shape while adding the desired gradient or pattern effect.

Repository (GitHub)

Topics

#border #gradient #dotted #dashed #widgetarian

Documentation

API reference

Funding

Consider supporting this project:

buymeacoffee.com
ko-fi.com

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on fancy_border