iconswitcher 1.0.3
iconswitcher: ^1.0.3

Flutter Android iOS web

A plugin to create an icon switcher to put on the AppBar Widget

IconSwitcher #

A Flutter plugin that allows you to create an icon switcher on the AppBar Widget

PARAMETERS #

NAMEDESCRIPTIONDEFAULT VALUE
widththe final Widget widthrequired
heightthe final Widget heightrequired
marginTopthe final Widget marginToprequired
icon1the first Iconrequired
icon2the second Iconrequired
color1the color of the first Iconrequired
color2the color of the second Iconrequired
firstIconSelectedColorthe color of the first selectorColors.redAccent
secondIconSelectedColorthe color of the second selectorColors.orangeAccent
durationthe animation duration when a user clicks on one of the iconsrequired
curvethe animation Curve typeCurves.bounceOut
onChangeFunction(bool): return true when the first Icon is selected; false otherwise

EXAMPLE OF USAGE

You can use it to create multiple screen views inside a same Widget using all the Flutter Animated Widgets

CODE:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:iconswitcher/iconswitcher.dart';

class screen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _screen();
  }
}

class _screen extends State<screen> with TickerProviderStateMixin {
  bool left = true;
  Duration duration = Duration(milliseconds: 400);

  @override
  Widget build(BuildContext context) {
    double marginTop = 1.5;
    double height = kToolbarHeight - marginTop * 2;
    double width = height * 2;

    return Scaffold(
          backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: Colors.white,
        title: Text(
          "Title",
        ),
        actions: <Widget>[
          IconSwitcher(
            width: width,
            height: height,
            marginTop: marginTop,
            color1: Colors.purple,
            color2: Colors.white,
            icon1: Icons.satellite,
            icon2: Icons.content_copy,
            firstIconSelectedColor: Colors.redAccent,
            secondIconSelectedColor: Colors.orangeAccent,
            backgroundColor: Colors.black,
            duration: duration,
            onChange: (bool result) {
              setState(() {
                left = result;
              });
            },
          )
        ],
      ),
      body: AnimatedCrossFade(
        firstChild: Container(
          color: Colors.black54,
        ),
        secondChild: Container(
          color: Colors.orange,
        ),
        duration: duration,
        crossFadeState:
        left ? CrossFadeState.showFirst : CrossFadeState.showSecond,
        firstCurve: Curves.bounceOut,
        secondCurve: Curves.bounceOut,
      ),
    );
  }
}


0
likes
90
pub points
19%
popularity

A plugin to create an icon switcher to put on the AppBar Widget

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

andrea.maranesi99@gmail.com

License

MIT (LICENSE)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on iconswitcher