Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 915 Bytes

README.md

File metadata and controls

30 lines (20 loc) · 915 Bytes

Fragment Args

Fragment arguments without ceremony thanks to delegated properties.

Supported platforms: Android.

Setup

If you want to use this dependency without using one of the fun packs, you can use Splitties.fragmentargs, provided you have refreshVersions added to the project.

For reference, the maven coordinates of this module are com.louiscad.splitties:splitties-fragmentargs.

Example

class YourFragment : Fragment() {

    var someRequiredId: Int by arg()
    var optionalArg: String? by argOrNull()
    var nonNullOptionalArg: String by argOrDefault("")
    var anotherNonNullOptionalArg: String by argOrElse { "splitties rock!".capitalize() }

    private fun yourMethod() = yourCode()
}

fun createYourFragment(someId: Int): Fragment = YourFragment().apply {
    someRequiredId = someId
}