Skip to content

hasanelfalakiy/flashbar

Repository files navigation

app_banner

flashbar

Alternative of snackbar and toast, powerful, customizable, beautiful and easy to use


latest_release jitpack build_with_kotlin License

Read in Indonesia

About Flashbar

Library for displaying messages as an alternative to snackbars and toast, which is powerful, easy to customize, and easy to use. Based on Flashbar (AndroidIDE) that based on Flashbar (aritraroy)

Configuration

  1. Put this code in settings.gradle.kts (root kotlin dsl) in repositories block
  dependencyResolutionManagement {
    repositories {
      // example
      maven {
        url = uri("https://jitpack.io")
      }
    }
  }

If using groovy dsl

  repositories {
    maven { url 'https://jitpack.io' }
  }
  1. Put dependencies into build.gradle.kts (app/build.gradle.kts kotlin dsl) inside the dependencies block
implementation("com.github.hasanelfalakiy:flashbar:${version}")

if using groovy dsl

implementation 'com.github.hasanelfalakiy:flashbar:${version}'

Read Dokka Documentation

Usage

1. Basic Usage (Activity/View)

Flashbar.Builder(this)
    .gravity(Flashbar.Gravity.TOP) // or BOTTOM
    .title("Hello World!")
    .message("This is a message from Flashbar.")
    .backgroundColorRes(R.color.colorPrimary)
    .build()
    .show()

2. Usage in Jetpack Compose

In Jetpack Compose, you can use LocalContext to get the Activity.

@Composable
fun MyScreen() {
    val context = LocalContext.current
    val activity = context as Activity

    Button(onClick = {
        Flashbar.Builder(activity)
            .message("Appears in Jetpack Compose!")
            .build()
            .show()
    }) {
        Text("Show Flashbar")
    }
}

3. Card Customization (New!)

You can now customize the appearance of Flashbar cards to be more flexible.

Flashbar.Builder(activity)
    .message("Custom Flashbar")
    // Set the elevation (shadow). Use 0f so there are no shadows
    .cardElevation(0f) 
    // Set the corner radius. Use 0f for perfect square corners
    .cardCornerRadius(0f)
    .build()
    .show()

Want to contribute?

If you want to contribute, please fork this repository, clone to your local machine, make changes, push, and then send a pull request to this repository

Contact us

License

Copyright 2016 aritraroy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
flashbar
Copyright (C) 2024 Akash Yadav (AndroidIDE)
... (License details are the same as before)
flashbar
Copyright (C) 2026 Andi Hasan Ashari
... (License details are the same as before)

About

Library to display awesome Flashbar

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages