Giter Site home page Giter Site logo

rydmike / annotated_region_demo Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 278 KB

Demo of AnnotatedRegion Widget with transparent system navigation bar

Kotlin 0.23% Swift 2.77% Objective-C 0.06% Dart 24.50% CMake 30.15% C++ 37.00% C 2.28% HTML 3.01%

annotated_region_demo's Introduction

Demo of transparent AnnotatedRegion

This repo was originally used to test issue: flutter/flutter#135657

But later modified to demonstrate usage of AnnotatedRegion to use transparent system navigation bar on Android.

Note that for this to work you must also set SystemUiMode.edgeToEdge so:

  // If opacity is specified, we need to enable SystemUiMode.edgeToEdge to
  // be able to see content scrolling behind the transparent bar. Only do
  // this when using opacity or transparent system navigation bar.
  await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);

In this example that is done in the main.dart file.

After that setting the transparent system navigation bar style is typically enough to do in the screen(s) that can chnage the theme mode between light and dark mode.

There you can do something like:

  @override
  Widget build(BuildContext context) {
    final bool isLight = Theme.of(context).brightness == Brightness.light;
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle(
        systemNavigationBarContrastEnforced: false,
        systemNavigationBarColor: Colors.transparent,
        systemNavigationBarDividerColor: Colors.transparent,
        systemNavigationBarIconBrightness:
            isLight ? Brightness.dark : Brightness.light,
      ),
      child: Scaffold(...),
    );

In this demo it is done in file settings_view.dart.

The bottom navigation bar on the home screen does not do anything, it is only there to show what it looks like when one is present. The theme settings and details page show the look when a navigator is not present.

The system nav also changes correctly in this demo when the ThemeMode.system is used and light/dark mode is toggled via Android system settings.

Getting Started

This project is a starting point for a Flutter application that follows the simple app state management tutorial.

For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Assets

The assets directory houses images, fonts, and any other files you want to include with your application.

The assets/images directory contains resolution-aware images.

Localization

This project generates localized messages based on arb files found in the lib/src/localization directory.

To support additional languages, please visit the tutorial on Internationalizing Flutter apps

annotated_region_demo's People

Contributors

rydmike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.