android - 错误 : The method `CircularNotchedRectangle` is not defined

标签 android ios flutter

我正在尝试使用 BottomAppBar 创建一个小部件。它正在使用 CircularNotchedRectangle 但它给了我这个错误:

The method CircularNotchedRectangle is not defined

有谁知道是什么原因吗?

import 'package:flutter/material.dart';
import 'package:roomie/screens/widgets/common_drawer.dart';

class CommonScaffold extends StatelessWidget {
  final appTitle;
  final Widget bodyData;
  final showFAB;
  final showDrawer;
  final backGroundColor;
  final actionFirstIcon;
  final scaffoldKey;
  final showBottomNav;
  final floatingIcon;
  final centerDocked;
  final elevation;

  CommonScaffold(
      {this.appTitle,
      this.bodyData,
      this.showFAB = false,
      this.showDrawer = false,
      this.backGroundColor,
      this.actionFirstIcon = Icons.search,
      this.scaffoldKey,
      this.showBottomNav = false,
      this.centerDocked = false,
      this.floatingIcon,
      this.elevation = 4.0});

  Widget myBottomBar() => new BottomAppBar(
        shape: CircularNotchedRectangle(),
        child: Ink(
          height: 50.0,
          decoration: new BoxDecoration(
              gradient: new LinearGradient(colors: UIData.kitGradients)),
          child: new Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              SizedBox(
                height: double.infinity,
                child: new InkWell(
                  radius: 10.0,
                  splashColor: Colors.yellow,
                  onTap: () {},
                  child: Center(
                    child: new Text(
                      "ADD TO WISHLIST",
                      style: new TextStyle(
                          fontSize: 12.0,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                  ),
                ),
              ),
              new SizedBox(
                width: 20.0,
              ),
              SizedBox(
                height: double.infinity,
                child: new InkWell(
                  onTap: () {},
                  radius: 10.0,
                  splashColor: Colors.yellow,
                  child: Center(
                    child: new Text(
                      "ORDER PAGE",
                      style: new TextStyle(
                          fontSize: 12.0,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: scaffoldKey != null ? scaffoldKey : null,
      backgroundColor: backGroundColor != null ? backGroundColor : null,
      appBar: AppBar(
        elevation: elevation,
        backgroundColor: Colors.black,
        title: Text(appTitle),
        actions: <Widget>[
          SizedBox(
            width: 5.0,
          ),
          IconButton(
            onPressed: () {},
            icon: Icon(actionFirstIcon),
          ),
          IconButton(
            onPressed: () {},
            icon: Icon(Icons.more_vert),
          )
        ],
      ),
      drawer: showDrawer ? CommonDrawer() : null,
      body: bodyData,
      floatingActionButton: showFAB
          ? CustomFloat(
              builder: centerDocked
                  ? Text(
                      "5",
                      style: TextStyle(color: Colors.white, fontSize: 10.0),
                    )
                  : null,
              icon: floatingIcon,
              qrCallback: () {},
            )
          : null,
      floatingActionButtonLocation: centerDocked
          ? FloatingActionButtonLocation.centerDocked
          : FloatingActionButtonLocation.endFloat,
      bottomNavigationBar: showBottomNav ? myBottomBar() : null,
    );
  }
}

最佳答案

由于没有人回答,我认为这可能是原因。已经有一些breaking changes最近使用了 API,因此如果您的版本不是最新的,您将需要使用以前的 BottomAppBar API:

BottomAppBar(shape: CircularNotchedRectangle()) 以前是 BottomAppBar(hasNotch: true)

Source

关于android - 错误 : The method `CircularNotchedRectangle` is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51972589/

相关文章:

android - 为什么 Realm 会为所有的模型类生成代理类?

ios - 如何在本地存储 UIImage 以避免不必要的服务器请求?

objective-c - UITableViewCell<MFMailComposeViewControllerDelegate> 崩溃 didReceiveMemoryWarning

android-studio - 如何从 Flutter App 中删除 Kotlin 支持?

flutter - body 不在 flutter 中使用 map 发送

java - 在服务内运行加速度计会出现 "Unable to create service"异常

android - 检查 Android 设备是否有软件或硬件导航按钮

Android - Calendar.getInstance 的小时值设置为零

ios - iOS 应用程序的 iPhone 语音识别?

flutter - 多个平台的文本字段警报对话框