Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Datetime 如何更改日期范围选择器的样式?_Datetime_Flutter - Fatal编程技术网

Datetime 如何更改日期范围选择器的样式?

Datetime 如何更改日期范围选择器的样式?,datetime,flutter,Datetime,Flutter,在颤振添加插件。这是我的代码 onPressed:() async { final List<DateTime> picked = await DateRagePicker.showDatePicker( context: context, initialFirstDate: DateTime.now(), initialLastDate: DateTime.now()).add(Duration(days: 7),

在颤振添加插件。这是我的代码

onPressed:() async {
    final List<DateTime> picked = await DateRagePicker.showDatePicker(
        context: context,
        initialFirstDate: DateTime.now(),
        initialLastDate: DateTime.now()).add(Duration(days: 7),
        firstDate: DateTime(2018),
        lastDate: DateTime(2022),
    );
    if (picked != null && picked.length == 2) {
        print(picked);
    }
},
onPressed:()异步{
最终选中列表=等待DateRagePicker.showDatePicker(
上下文:上下文,
initialFirstDate:DateTime.now(),
initialLastDate:DateTime.now()).add(持续时间:7天),
firstDate:DateTime(2018年),
最后日期:日期时间(2022年),
);
if(picked!=null&&picked.length==2){
打印(已拾取);
}
},
这就是结果。
那么,我如何更改此插件的样式和语言呢?

对于语言,您可以设置
语言环境。我还建议调查一下

要更改小部件的颜色、字体等,必须将元素包装到主题中:

Widget returnRangePicker(BuildContext context) {
    return Theme(
      data: Theme.of(context).copyWith(
          accentColor: Colors.green,
          primaryColor: Colors.blue,
          buttonTheme: ButtonThemeData(
              highlightColor: Colors.green,
              buttonColor: Colors.green,
              colorScheme: Theme.of(context).colorScheme.copyWith(
                  secondary: epapGreen,
                  background: Colors.white,
                  primary: Colors.green,
                  primaryVariant: Colors.green,
                  brightness: Brightness.dark,
                  onBackground: Colors.green),
              textTheme: ButtonTextTheme.accent)),
      child: Builder(
        builder: (context) => FlatButton(
          onPressed: () async {
            final List<DateTime> picked = await DateRangePicker.showDatePicker(
                context: context,
                initialFirstDate: DateTime.now(),
                initialLastDate:
                    DateTime.now()).add(Duration(days: 7),
                firstDate: DateTime(2015),
                lastDate: DateTime(2020));
            if (picked != null && picked.length == 2) {
              print(picked);
            }
          },
          child: Text(
            "Choose range",
            style: TextStyle(color: Colors.green),
          ),
        ),
      ),
    );
  }

Widget returnRangePicker(构建上下文){
返回主题(
数据:Theme.of(context).copyWith(
accentColor:Colors.green,
原色:颜色。蓝色,
buttonTheme:buttonTheme数据(
highlightColor:Colors.green,
按钮颜色:Colors.green,
colorScheme:Theme.of(context).colorScheme.copyWith(
中学:epapGreen,
背景:颜色。白色,
原色:颜色。绿色,
主要变体:颜色。绿色,
亮度:亮度。暗,
onBackground:颜色。绿色),
textTheme:buttonexttheme.accent),
孩子:建筑工人(
生成器:(上下文)=>FlatButton(
onPressed:()异步{
最终选择列表=等待DateRangePicker.showDatePicker(
上下文:上下文,
initialFirstDate:DateTime.now(),
初始截止日期:
DateTime.now()).add(持续时间(天:7),
firstDate:DateTime(2015年),
最后日期:日期时间(2020年);
if(picked!=null&&picked.length==2){
打印(已拾取);
}
},
子:文本(
“选择范围”,
样式:TextStyle(颜色:Colors.green),
),
),
),
);
}