簡體   English   中英

如何刪除 SearchDelegate 中的高程(陰影)?

[英]How to remove the elevation (shadow) in a SearchDelegate?

我想在使用SearchDelegate時從搜索欄中刪除陰影,但我找不到方法。 有小費嗎?

截屏

這基本上是所有的代碼:

showSearch(
  context: context,
  delegate: CustomSearchDelegate(),
);

CustomSearchDelegate() 只包含一個空的搜索委托小部件/類。

在 Searchdelegate 類中添加:

 @override
  ThemeData appBarTheme(BuildContext context){
    assert(context != null);
    final ThemeData theme = Theme.of(context);
    assert(theme != null);
    return theme.copyWith(
      primaryColor: Colors.grey[50],

    );
  }

這是主要的應用程序主題:

MaterialApp(
      theme: ThemeData(
        backgroundColor: Colors.white,
        appBarTheme: AppBarTheme(elevation: 0.0), //This is important
      title: 'Flutter Demo',
      home: MyHomePage(),
    );

在您的ThemeData()相應的更改並添加appBarTheme: AppBarTheme(elevation: 0.0),以刪除高程和 SearchDelegate 主題,因為它是您的搜索委托類,它將確保您的材料應用程序的 ThemeData 中定義的高程是實施的。

注意:我猜,ThemeData 中設置的高度也會影響整個應用程序其他頁面中應用欄的高度。

結果:輸出圖像

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM