如何编辑flappy_search_bar flutter包?

问题描述 投票:0回答:1

我想编辑flappy_search_bar的某些功能

enter image description here

如您所见,加载微调器是蓝色的,我似乎无法将其编辑为任何其他颜色。我也无法编辑同样为蓝色的光标颜色。

这里是我当前代码块的副本:

 @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: SearchBar<Post>(
          searchBarPadding: EdgeInsets.symmetric(horizontal: 20),
          headerPadding: EdgeInsets.symmetric(horizontal: 10),
          listPadding: EdgeInsets.symmetric(horizontal: 10),
          onSearch: _getALlPosts,
          hintStyle: TextStyle(color: Colors.black87),
          hintText: 'Search',
          iconActiveColor: Colors.deepPurpleAccent,
//          cursorColor: Colors.deepPurpleAccent,
//          loader: Colors.deepPurpleAccent,
          textStyle: TextStyle(
            fontFamily: 'OpenSans',
            fontSize: 18.0,
          ),`

到目前为止,我已经尝试直接在搜索栏中进行编辑,如上所示,添加扩展代码如下:

 class Styling extends SearchBar {
  Styling(this.cursorColor);
  final Color cursorColor;
  static const accentColor = Colors.deepPurpleAccent;

  @override
  Widget build(BuildContext context) {
    return Theme(
//      data: Theme.of(context).copyWith(
//        cursorColor: Theme.of(context).accentColor,
//      ),
        );
  }
}

我也尝试过直接编辑软件包文件,但这也不成功。

有人建议如何编辑flippy_search_bar程序包的光标颜色和加载微调器颜色吗?

flutter flutter-layout flutter-dependencies
1个回答
0
投票

我也一直试图做到这一点,并设法做到了。

要编辑光标,请将以下内容应用于ThemeData下的顶级MaterialApp:

cursorColor: Colors.red,
cupertinoOverrideTheme: CupertinoThemeData(
    primaryColor: Colors.red,
),

这将在[[ALL TextFields中设置光标的颜色,我不知道如何仅针对flappy_search_bar小部件中的TextField对其进行编辑

关于加载指示,请在您使用的SearchBar下添加:

SearchBar<SomeClass>( .... loader: const Center(child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation<Color>(Colors.red))), .... );

这是小部件内部的功能,如果您查看源代码。将Colors.red更改为所需的任何颜色。

希望有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.