본문 바로가기

개발일지/Flutter

appBar에서 PreferredSizeWidget 오류 발생시.

Widget build(BuildContext context) {
    return Scaffold(
      appBar: navigationBar(widget.groupChannel),
      body: body(context),
    );
  }
  

  Widget navigationBar(GroupChannel channel) {
    return AppBar(
      automaticallyImplyLeading: true,
      backgroundColor: Colors.white,
      centerTitle: false,

위와 같은 코드에서 navigationBar에서 PreferredSizedWidget 과 관련된 오류 발생.

 

@override
  Widget build(BuildContext context) {
    return Scaffold(
      // backgroundColor: Colors.white,
      appBar: navigationBar(),
      body: body(context),
    );
  }

  PreferredSize navigationBar() {
    return PreferredSize(
        preferredSize: const Size.fromHeight(100),
        child: AppBar(
          automaticallyImplyLeading: true,
          backgroundColor: Colors.white,

PreferredSize 위젯을 사용하여 height size를 주면 문제 해결.