android

[Flutter] 상단 상태바, 시스템 네비게이션바 색상 변경.

nowoodeel 2021. 5. 30. 22:04
728x90

SystemChrome.setSystemUIOverlayStyle를 사용한다.

import 'package:flutter/services.dart';

// dark
@override
Widget build(BuildContext context) {
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
  return const Placeholder();
}

// statusBarColor
@override
Widget build(BuildContext context) {
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
  	statusBarColor: Colors.red
  ));
  return const Placeholder();
}

// systemNavigationBarColor
@override
Widget build(BuildContext context) {
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
  	systemNavigationBarColor: Colors.blue
  ));
  return const Placeholder();
}

// statusBarColor, systemNavigationBarColor
@override
Widget build(BuildContext context) {
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
    systemNavigationBarColor: Colors.blue,
    statusBarColor: Colors.red,
  ));
  return const Placeholder();
}

 

 

setSystemUIOverlayStyle method - SystemChrome class - services library - Dart API

void setSystemUIOverlayStyle(SystemUiOverlayStyle style ) Specifies the style to use for the system overlays that are visible (if any). This method will schedule the embedder update to be run in a microtask. Any subsequent calls to this method during the c

api.flutter.dev

 

반응형