picture_button 0.1.1 copy "picture_button: ^0.1.1" to clipboard
picture_button: ^0.1.1 copied to clipboard

Flutter PictureButton Widget, If you just put the image inside PictureButton, you can use it like a other button

Pub Version

PictureButton is setting only Image(ImageProvider type) and onPressed. like ButtonStyle.
I am very happy that I somehow seem to have deployed a useful widget.


Features ๐Ÿœ #

GIF

Getting started ๐ŸŒฑ #

My example image(google sign image)
path : [project]/assets/

Screenshot


Grant assets path from pubspec.yaml
path : [project]/pubspec.yaml

flutter:

 # The following line ensures that the Material Icons font is
 # included with your application, so that you can use the icons in
 # the material Icons class.
 uses-material-design: true

 assets:
   - assets/

Add

flutter pub add picture_button

Import

import 'package:picture_button/picture_button.dart';


Update ๐Ÿญ #

Add vibrate parameter from 0.0.10 version.
You can set vibration effect.
It just input true or false parameter that is bool type.
That is default setting true.

 PictureButton(
   onPressed: () {
     
   },
   image: const AssetImage("assets/google_sign_image.png"),
   vibrate: false,  // default, true.
 ),

Usage ๐Ÿš€ #

parameter required type default
onPressed โœ”๏ธ VoidCallback
onLongPressed โŒ VoidCallback?
onSelectChanged โŒ Function(bool isSelected)?
image โœ”๏ธ ImageProvider
imagePressed โŒ ImageProvider?
imageSelected โŒ ImageProvider?
width โŒ double? imageWidth
height โŒ double? imageHeight
fit โŒ BoxFit BoxFit.contain
margin โŒ EdgeInsets?
opacity โŒ double 1.0
border โŒ Border?
borderRadius โŒ BorderRadius?
borderRadiusInk โŒ BorderRadius?
paddingInk โŒ EdgeInsetGeometry EdgeInsets.zero
backgroundColor โŒ Color?
splashColor โŒ Color?
highlightColor โŒ Color?
focusColor โŒ Color?
hoverColor โŒ Color?
enabled โŒ bool true
vibrate โŒ bool true
useBubbleEffect โŒ bool false
bubbleEffect โŒ PictureBubbleEffect? PictureBubbleEffect.shrink
child โŒ Widget?

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ AssetImage(..), NetworkImage(..), FileImage(..), MemoryImage(..)

 PictureButton(
   onPressed: () {
     
   },
   image: const AssetImage("assets/google_sign_image.png"),
 ),

๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Image.asset(..), Image.network(..), Image.file(..), Image.memory(..)

Use later .image getter function.

 PictureButton(
   onPressed: () {
     
   },
   image: Image.asset("assets/google_sign_image.png").image,
 ),

๐Ÿ›€ Bubble Effect

useBubbleEffect: true

 PictureButton(
   onPressed: () {
     
   },
   image: Image.asset("assets/google_sign_image.png").image,
   useBubbleEffect: true,
   bubbleEffect: PictureBubbleEffect.shrink, // [shrink, expand]
 ),

๐Ÿ–Œ If you don't want Effect(Ripple) Color (I said 'Ink')

splashColor: Colors.transparent
highlightColor: Colors.transparent

 PictureButton(
   onPressed: () {
     
   },
   image: Image.asset("assets/google_sign_image.png").image,
   highlightColor: Colors.transparent,
   splashColor: Colors.transparent,
 ),

โœ‚ Measure Ripple Effect BorderRadius

borderRadiusInk: BorderRadius.circular(8.0)

 PictureButton(
   onPressed: () {
     
   },
   image: Image.asset("assets/google_sign_image.png").image,
   borderRadiusInk: BorderRadius.circular(8.0),
   // paddingInk: EdgeInsets.all(8.0),   if you want measure 'Ink' padding.
 ),

๐Ÿˆ Pressed Button Image

Add imagePressed parameter from 0.0.8 version.
You can see the pressed image when you implement onPressed event.

GIF
 PictureButton(
   onPressed: () {
     
   },
   image: Image.asset("assets/icon_flutter_default.png").image,
   imagePressed: Image.asset("assets/icon_flutter_pressed.png").image,
   ...
 )

๐ŸŒ— Toggle Button

Add imageSelected and onSelectChanged parameters from 0.0.9 version.
You can toggle action from this release.
When you want to see toggle action, Certainly define imageSelected and onSelectChanged parameters.
If you do not define one, there do not work.

GIF
 PictureButton(
   onPressed: () {
     
   },
   onSelectChanged: (isSelected) {
     
   },
   image: Image.asset("assets/icon_flutter_default.png").image,
   imagePressed: Image.asset("assets/icon_flutter_pressed.png").image,
   imageSelected: Image.asset("assets/icon_flutter_other.png").image,
 )

3
likes
160
points
200
downloads

Publisher

verified publisherlagerstroemia.net

Weekly Downloads

Flutter PictureButton Widget, If you just put the image inside PictureButton, you can use it like a other button

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on picture_button