Git Product home page Git Product logo

teatalkinternal / favorite_button Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 5.0 75 KB

Favorite Button is a flutter library that allows you to create heart and star shaped favorite featured buttons with animation effects too

Home Page: https://pub.dev/packages/favorite_button

License: MIT License

Kotlin 3.11% Swift 3.63% Objective-C 0.34% Dart 92.92%
heart flutter-library dart flutter flutter-examples hacktoberfest hacktoberfest-accepted open-source pub-package

favorite_button's Introduction

favorite_button

Language: English

Favorite Button is a flutter library that allows you to create heart and star shaped favorite featured buttons with animation effects too.

How to use it.

the default effects is Icons.favorite

  FavoriteButton(
            valueChanged: (_) {
            },
          ),

and you can also define custom effects.

 FavoriteButton(
            valueChanged: (_isFavorite) {
              print('Is Favorite $_isFavorite)');
            },
          )

parameters

parameter description default
iconSize size of button widget 60.0
iconColor color of button widget red for heart and yellow for star button respectively
valueChanged Function that returns boolean value for current state of button This is a required parameter
isFavorite or isStarred Default state of button This is a optional parameter
                                                                                                                                                           |

more detail

favorite_button's People

Contributors

dochan-consultis avatar himanshu64 avatar vishalkevin11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

favorite_button's Issues

adding as favorite conditionally

I have a listview and for each row, I added the option to add it as a favorite. I also have a condition in the backend that if the number of favorites is more than 10, the responsecode equals to 2 and shows an error in the flutter and does not add it to the favorite.

Everything works perfectly. The only problem that I have is that in conditions with more than 10 favorites, however, it does not add it to the list (when I refresh the page, it hsows as unmarked), but when I click, it marks as favorite. How could I unmark it as favorite, for example, when user closes the showDialog?

Any other approach is also appreciated like simulating the onpressed action to undo the action of favoriting.

Thank you in advance.

StarButton(
  isStarred: UserFavorite
      .Users!
  valueChanged: (_isStarred) {
    if (_isStarred == true)
      setState(() async {
        var resp =
            await add(
                widget.oauth,
                widget.gatewayId,);
        if (resp.responseCode ==
            2) {
          await showDialog(
            context: context,
            builder:
                (alertDialogContext) {
              return AlertDialog(
                title: Text(
                    'Limit Reached'),
                content: Text(
                    'You are allowed to add up to 10 sensors as your favorite.'),
                actions: [
                  TextButton(
                    child: Text(
                        'Ok'),
                    onPressed:
                        () {
                      Navigator.pop(
                          alertDialogContext);
                    },
                  ),
                ],
              );
            },
          );
        }
      });
    else
      setState(() {
        delete(
            widget.oauth,
            widget.Id,
       );
      });
  },
)

favorite_problem

bug

hi, Ms/TeaTalk

when i add favorite button in listview with listTile ,i press the heart icon and the color change to red but when i move the listview up and down the color red is Disappears..please help me and thanks

How to set default value for _isFavorite

If a user has already added something as a favorite how do we implement that by setting the default value of _isFavorite=True in the following code?

FavoriteButton(
	iconSize: 8,
	iconColor: Colors.redAccent,
	valueChanged: (_isFavorite) {
	  print('Is Favorite : $_isFavorite');
	},
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.