Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

sysnavbar with flexcolorscheme

transparent android system navigation bar with flutter and flexcolorscheme.

about this example

this an extra android companion example to the flutter
package flexcolorscheme.

it is a slight modification of example nr 5 bundled with the package and shows
how flexcolorscheme can be used to make a transparent system navigation bar in
flutter android applications.

android setup

to make transparent system navigation bar in flutter you must also make this change to them mainactivity.kt
file in your flutter android embedder:

in ../android/app/src/main the default mainactivity.kt for your project:

package com.rydmike.sysnavbar  // replace with your package name

import io.flutter.embedding.android.flutteractivity

class mainactivity: flutteractivity() {
}

is changed to:

package com.rydmike.sysnavbar  // replace with your package name

import android.os.build
import android.os.bundle
import io.flutter.embedding.android.flutteractivity

class mainactivity: flutteractivity() {
    override fun oncreate(savedinstancestate: bundle?) {
        super.oncreate(savedinstancestate)
        if (build.version.sdk_int >= build.version_codes.r) {
            window.setdecorfitssystemwindows(false)
        }
    }
}

additionally, you must use android sdk 30 to build the flutter android project, so you also need to update
your build.gradle file in ../android/app from:

 :
android {
compilesdkversion 29

    sourcesets {
        main.java.srcdirs += 'src/main/kotlin'
    }

    lintoptions {
        disable 'invalidpackage'
    }

    defaultconfig {
        applicationid "com.rydmike.sysnavbar"
        minsdkversion 16
        targetsdkversion 29
        versioncode flutterversioncode.tointeger()
        versionname flutterversionname
    }
  :

to be:

 :
android {
compilesdkversion 30

    sourcesets {
        main.java.srcdirs += 'src/main/kotlin'
    }

    lintoptions {
        disable 'invalidpackage'
    }

    defaultconfig {
        applicationid "com.rydmike.sysnavbar"
        minsdkversion 16
        targetsdkversion 30
        versioncode flutterversioncode.tointeger()
        versionname flutterversionname
    }
  :

you can find additional info and discussion about transparent system navigation in flutter android apps in
flutter issue 69999, it was that discussion that lead me
to adding this experimental support for it in flexcolorscheme.

support both transparent and color branded sysnavbar

when you want to use color branded system navigation bar it is best to never put any transparency on it if it is not
supported. adding transparency to the system navigation bar color when it is not supported, will just make
the color on it transparent and show the default scrim color used on the system navigation bar. this will not look
very nice.

if you design your app to use transparent system navigation bar when it is supported, and then want to use and have a
nice looking color branded background colored system navigation bar, when transparency is not supported, then we must
check which android sdk level the application is running on and adjust the behaviour accordingly. we can use the
package device_info to get the android sdk level and keep the opacity as 1 when sdk level is below 30.

this example presents one suggestion on how this can be implemented, and the different approach to the design for
the use cases.

in the sub-page in this example, it also shows how you can use a fully transparent system navigation bar when possible,
and for the case when this is not possible, a color branded opaque one. then combine this with a same background primary
color branded material bottomnavigationbar using a slight transparency. for the case that support
transparency on the system navigation bar, when it is placed on top of this bottomnavigationbar with its slight
transparency, it makes bottomnavigationbar and system navigation bar look like one shared translucent bottom area,
with content scrolling behind it.

for the case when the system navigation bar transparency is not supported, it still has
the same color as the bottomnavigationbar, but without the transparency, so it does not clash so badly
with it. the bottomnavigationbar still keeps it slight transparency, and we can at least see content scrolling behind
it.

instead of just transparency on the bottom navigation bar, you can add a container to it with blur filter in it,
you can then recreate the ios frosted glass blur effect and have that on the system navigation bar too.
this is not shown in this demo, but is e.g. used by one of the configuration options offered for material
bottomnavigationbar in flexfold.

the end result is an app looking like the left one, when transparency is supported and like the right one,
when it is not. i kind of like it.

this setup also supports the much smaller android system navigation bar you get when the phone is configured to
use gestures. some android implementations don’t even use a visible system navigation bar when gestures are enabled,
this configuration also works with such android implementation, like e.g. oneplus gestures.

sysnavbar4


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.