outline_gradient_button 1.0.0+2

wow

Example #

Take a look at the provided example for how to use the OutlineGradientButton.

How to use #

demo_button1

OutlineGradientButton(
  child: Text('WOW'),
  gradient: LinearGradient(
    colors: [Colors.purple, Colors.pink],
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
  ),
  strokeWidth: 4,
),

demo_button2

OutlineGradientButton(
  child: Text('TEXT'),
  gradient: LinearGradient(colors: [Colors.pink, Colors.purple]),
  strokeWidth: 4,
  radius: Radius.circular(8),
),

demo_button3

OutlineGradientButton(
  child: Text('OMG'),
  gradient: LinearGradient(
    stops: [0, 0.5, 0.5, 1],
    colors: [Colors.green, Colors.green, Colors.red, Colors.red],
  ),
  strokeWidth: 4,
  corners: Corners(topLeft: Radius.elliptical(16, 14), bottomRight: Radius.circular(6)),
),

demo_button4

OutlineGradientButton(
  child: SizedBox(
    width: 52,
    height: 52,
    child: Column(
      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Icon(Icons.opacity, color: Colors.grey, size: 24),
        Text('TEXT', style: TextStyle(fontSize: 9)),
      ],
    ),
  ),
  gradient: LinearGradient(
    colors: [Colors.blue, Colors.black],
    begin: Alignment(-1, -1),
    end: Alignment(2, 2),
  ),
  strokeWidth: 4,
  padding: EdgeInsets.zero,
  radius: Radius.circular(26),
),

demo_button5

OutlineGradientButton(
  child: Text('Linear gradient', style: TextStyle(color: Colors.black, fontSize: 10)),
  gradient: LinearGradient(
    colors: List.generate(360, (h) => HSLColor.fromAHSL(1, h.toDouble(), 1, 0.5).toColor()),
  ),
  strokeWidth: 2,
  padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
  radius: Radius.circular(8),
),

demo_button6

OutlineGradientButton(
  child: Text('Sweep gradient', style: TextStyle(color: Colors.black, fontSize: 10)),
  gradient: SweepGradient(
    colors: List.generate(360, (h) => HSLColor.fromAHSL(1, h.toDouble(), 1, 0.5).toColor()),
  ),
  strokeWidth: 2,
  padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
  radius: Radius.circular(8),
),

demo_button7

OutlineGradientButton(
  child: Text('With background color and elevation', style: TextStyle(color: Colors.white, fontSize: 12)),
  gradient: LinearGradient(colors: [Colors.greenAccent, Colors.yellow]),
  strokeWidth: 2,
  padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
  corners: Corners(topRight: Radius.circular(16), bottomRight: Radius.circular(16)),
  backgroundColor: Colors.lightBlue,
  elevation: 4,
  inkWell: true,
  onTap: () => showSnack('onTap'),
  onDoubleTap: () => showSnack('onDoubleTap'),
  onLongPress: () => showSnack('onLongPress'),
),

[1.0.0] - 01.06.2020

  • Release version

example/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/rendering.dart';
import 'package:outline_gradient_button/outline_gradient_button.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  final scaffoldKey = new GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        key: scaffoldKey,
        appBar: AppBar(title: Text('Outline gradient buttons demo')),
        backgroundColor: Colors.white,
        body: Container(
          width: double.infinity,
          child: SingleChildScrollView(
            padding: EdgeInsets.all(48),
            child: Wrap(
              spacing: 24,
              runSpacing: 48,
              runAlignment: WrapAlignment.center,
              alignment: WrapAlignment.center,
              crossAxisAlignment: WrapCrossAlignment.center,
              children: _buildChildren(),
            ),
          ),
        ),
      ),
    );
  }

  List<Widget> _buildChildren() {
    return [
      OutlineGradientButton(
        child: Text('WOW'),
        gradient: LinearGradient(
          colors: [Colors.purple, Colors.pink],
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter,
        ),
        strokeWidth: 4,
      ),
      OutlineGradientButton(
        child: Text('TEXT'),
        gradient: LinearGradient(colors: [Colors.pink, Colors.purple]),
        strokeWidth: 4,
        radius: Radius.circular(8),
      ),
      OutlineGradientButton(
        child: Text('OMG'),
        gradient: LinearGradient(
          stops: [0, 0.5, 0.5, 1],
          colors: [Colors.green, Colors.green, Colors.red, Colors.red],
        ),
        strokeWidth: 4,
        corners: Corners(topLeft: Radius.elliptical(16, 14), bottomRight: Radius.circular(6)),
      ),
      OutlineGradientButton(
        child: SizedBox(
          width: 52,
          height: 52,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Icon(Icons.opacity, color: Colors.grey, size: 24),
              Text('TEXT', style: TextStyle(fontSize: 9)),
            ],
          ),
        ),
        gradient: LinearGradient(
          colors: [Colors.blue, Colors.black],
          begin: Alignment(-1, -1),
          end: Alignment(2, 2),
        ),
        strokeWidth: 4,
        padding: EdgeInsets.zero,
        radius: Radius.circular(26),
      ),
      OutlineGradientButton(
        child: Text('Linear gradient', style: TextStyle(color: Colors.black, fontSize: 10)),
        gradient: LinearGradient(
          colors: List.generate(360, (h) => HSLColor.fromAHSL(1, h.toDouble(), 1, 0.5).toColor()),
        ),
        strokeWidth: 2,
        padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
        radius: Radius.circular(8),
      ),
      OutlineGradientButton(
        child: Text('Sweep gradient', style: TextStyle(color: Colors.black, fontSize: 10)),
        gradient: SweepGradient(
          colors: List.generate(360, (h) => HSLColor.fromAHSL(1, h.toDouble(), 1, 0.5).toColor()),
        ),
        strokeWidth: 2,
        padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
        radius: Radius.circular(8),
      ),
      OutlineGradientButton(
        child: Text('With background color and elevation', style: TextStyle(color: Colors.white, fontSize: 12)),
        gradient: LinearGradient(colors: [Colors.greenAccent, Colors.yellow]),
        strokeWidth: 2,
        padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
        corners: Corners(topRight: Radius.circular(16), bottomRight: Radius.circular(16)),
        backgroundColor: Colors.lightBlue,
        elevation: 4,
        inkWell: true,
        onTap: () => showSnack('onTap'),
        onDoubleTap: () => showSnack('onDoubleTap'),
        onLongPress: () => showSnack('onLongPress'),
      ),
    ];
  }

  void showSnack(String text) {
    scaffoldKey.currentState
      ..removeCurrentSnackBar()
      ..showSnackBar(SnackBar(content: Text(text)));
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  outline_gradient_button: ^1.0.0+2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:outline_gradient_button/outline_gradient_button.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Feb 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test