alanchan-dev / OmniDateTimePicker

A Flutter DateTime picker package.
MIT License
46 stars 64 forks source link

How to customize the theme of the OmniDateTimePicker #30

Closed ghost closed 1 year ago

ghost commented 1 year ago

Is there a way to customize the theme of the OmniDateTimePicker? Especially in dark mode the picker does not look as expected, and at least not as nice as on the description screenshots. I tried to wrap the corresponding TextField() with onTap handler into a Theme() widget and I also tried different solutions from https://stackoverflow.com/questions/50321182/how-to-customize-a-date-picker, but that didn't help.

alanchan-dev commented 1 year ago

Hi @stefan-weinand, currently the theme of the OmniDateTimePicker follows the theme of your app, which is defined in your MaterialApp, the one in the screenshots can be reproduced with this code:

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Flutter Demo',
        theme: ThemeData(
          useMaterial3: true,
          colorSchemeSeed: Colors.blue,
          brightness: Brightness.dark,
        ),
        home: const Home());
  }
}

If you wish to have a finer control of the theme that only affects the OmniDateTimePicker widget, I'll create a property that accepts a ThemeData. Is that what you need?

ghost commented 1 year ago

Yes, a showOmniDateTimePicker() method with a builder or a themeData property would be great! :)

alanchan-dev commented 1 year ago

@stefan-weinand I've publish v1.0.7 with the proposed feature, you can try it out with something like this:

await showOmniDateTimePicker(
                  context: context,
                  isForce2Digits: true,
                  isShowSeconds: true,
                  is24HourMode: true,
                  theme: ThemeData(
                    useMaterial3: true,
                    colorSchemeSeed: Colors.yellow,
                    brightness: Brightness.dark,
                  ),
                ); 

By passing in a ThemeData into a theme property.

ghost commented 1 year ago

Oh my god, how awesome is that! Thank you very much!!!! 👍 🥇 💯

alanchan-dev commented 1 year ago

@stefan-weinand No problem, much appreciated if you would kindly star this repo. I'll close this issue for now.