実現したいこと
- 'brightness' is deprecated and shouldn't be used. This property is no longer used, please use systemOverlayStyle instead. This feature was deprecated after v2.4.0-0.0.pre..Try replacing the use of the deprecated member with the replacement.を現在のFlutterが推奨する使い方にして、安定した挙動を得たい。
前提
FlutterでFacebook UIの作り方を勉強しています。
AppBarを作成中に以下のメッセージが吐かれました。
発生している問題・エラーメッセージ
brightness' is deprecated and shouldn't be used. This property is no longer used, please use systemOverlayStyle instead. This feature was deprecated after v2.4.0-0.0.pre.. Try replacing the use of the deprecated member with the replacement.
該当のソースコード
home_screen.dart
1import 'package:facebook_clone/config/palette.dart'; 2import 'package:facebook_clone/widgets/circle_button.dart'; 3import 'package:flutter/material.dart'; 4import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; 5 6class HomeScreen extends StatelessWidget { 7 const HomeScreen({super.key}); 8 9 @override 10 Widget build(BuildContext context) { 11 return Scaffold( 12 body: CustomScrollView( 13 slivers: [ 14 SliverAppBar( 15 brightness: Brightness.light, 16 backgroundColor: Colors.white, 17 title: Text( 18 "facebook", 19 style: TextStyle( 20 color: Palette.facebookBlue, 21 fontSize: 28.0, 22 fontWeight: FontWeight.bold, 23 letterSpacing: -1.2, 24 ), 25 ), 26 centerTitle: false, 27 floating: true, 28 actions: [ 29 CircleButton( 30 icon: Icons.search, 31 iconSize: 30.0, 32 onPressed: () => print("Search"), 33 ), 34 CircleButton( 35 icon: MdiIcons.facebookMessenger, 36 iconSize: 30.0, 37 onPressed: () => print("Messenger"), 38 ), 39 ], 40 ), 41 ], 42 ), 43 ); 44 } 45} 46
palette.dart
1import 'package:flutter/material.dart'; 2 3class Palette { 4 static const Color scaffold = Color(0xFFF0F2F5); 5 6 static const Color facebookBlue = Color(0xFF1777F2); 7 8 static const LinearGradient createRoomGradient = LinearGradient( 9 colors: [ 10 Color(0xFF496AE1), 11 Color(0xFFCE48B1), 12 ], 13 ); 14 15 static const Color online = Color(0xFF4BCB1F); 16 17 static const LinearGradient storyGradient = LinearGradient( 18 colors: [ 19 Colors.transparent, 20 Colors.black26, 21 ], 22 begin: Alignment.topCenter, 23 end: Alignment.bottomCenter, 24 ); 25} 26
circle_button.dart
1import 'package:flutter/material.dart'; 2 3class CircleButton extends StatelessWidget { 4 final IconData icon; 5 final double iconSize; 6 final VoidCallback? onPressed; 7 const CircleButton({ 8 super.key, 9 required this.icon, 10 required this.iconSize, 11 required this.onPressed, 12 }); 13 14 @override 15 Widget build(BuildContext context) { 16 return Container( 17 margin: EdgeInsets.all(6.0), 18 decoration: BoxDecoration( 19 color: Colors.grey[200], 20 shape: BoxShape.circle, 21 ), 22 child: IconButton( 23 onPressed: onPressed, 24 icon: Icon(icon), 25 color: Colors.black, 26 iconSize: iconSize, 27 ), 28 ); 29 } 30} 31
試したこと
'brightness' is deprecated and shouldn't be used. This property is no longer used, please use systemOverlayStyle instead. This feature was deprecated after v2.4.0-0.0.pre.. Try replacing the use of the deprecated member with the replacement.を和訳したところ、brightnessは非推奨なのでsystemOverlayStyleを使って欲しいという意味だと判明。
systemOverlayStyle flutterでググったところ、以下のページにヒット。
https://zenn.dev/mukkun69n/articles/a6256eaae498fb
https://api.flutter.dev/flutter/services/SystemUiOverlayStyle-class.html
記事をもとにSliverAppBar内でsystemOverlayStyleを使ってコーディングしたものの、エラー頻発で15分経ってもsystemOverlayStyleを使って実装できなかったので今回質問させていただくことにしました。
補足情報(FW/ツールのバージョンなど)
お手本に使っている動画
https://www.youtube.com/watch?v=HvLb5gdUfDE&t=62s
[✓] Flutter (Channel stable, 3.7.0, on macOS 13.1 22C65
darwin-x64, locale ja-JP)
[✓] Android toolchain - develop for Android devices
(Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.74.3)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

あなたの回答
tips
プレビュー