Want to customize a date picker in flutter? There is builder parameter available with showDatePicker() method.
See the below example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | const MaterialColor buttonTextColor = const MaterialColor( 0xFF4A5BF6, const <int, Color>{ 50: const Color(0xFF4A5BF6), 100: const Color(0xFF4A5BF6), 200: const Color(0xFF4A5BF6), 300: const Color(0xFF4A5BF6), 400: const Color(0xFF4A5BF6), 500: const Color(0xFF4A5BF6), 600: const Color(0xFF4A5BF6), 700: const Color(0xFF4A5BF6), 800: const Color(0xFF4A5BF6), 900: const Color(0xFF4A5BF6), }, ); showDatePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(2018), lastDate: DateTime(2030), builder: (BuildContext context, Widget child) { return Theme( data: ThemeData.light().copyWith( primarySwatch: buttonTextColor,//OK/Cancel button text color primaryColor: const Color(0xFF4A5BF6),//Head background accentColor: const Color(0xFF4A5BF6)//selection color //dialogBackgroundColor: Colors.white,//Background color ), child: child, ); }, ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.