Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show different date pickers on iOS and Android (native ones) in Flutter?

I would like to show the native date picker depending on the device. For example UIDatePicker if it's iOS.

I've tried to add SelectDateTextField inside my widget and it works, but it looks like the Android one. Does anyone have any recommendations?

like image 663
aleksy.t Avatar asked Nov 24 '25 13:11

aleksy.t


1 Answers

You should check the Platform then need to write specific widgets as per your need.

Use the APIs provided by the Dart.

Example:

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';

Your Widget

Platform.isIOS ? CupertinoWidget() : MaterialWidget()
like image 200
ibhavikmakwana Avatar answered Nov 28 '25 15:11

ibhavikmakwana