3

In flutter added this plugin.This is my code

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);
    }
},

This is the resultDs. So how can I change style and language of this plugin?

Augustin R
  • 7,089
  • 3
  • 26
  • 54
Brutal
  • 798
  • 1
  • 14
  • 37

1 Answers1

3

For language you can set locale. I would also suggest looking into https://flutter.dev/docs/development/accessibility-and-localization/internationalization

To change widget colors, fonts ant etc. would have to wrap element into Theme:

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),
          ),
        ),
      ),
    );
  }

Augustin R
  • 7,089
  • 3
  • 26
  • 54
Adelina
  • 10,915
  • 1
  • 38
  • 46