<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pallavii Sharrma</title>
    <description>The latest articles on DEV Community by Pallavii Sharrma (@sharrmapallavii).</description>
    <link>https://dev.to/sharrmapallavii</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3334702%2F126b9b43-cb43-44cb-86e1-0a0805b9c0d2.jpg</url>
      <title>DEV Community: Pallavii Sharrma</title>
      <link>https://dev.to/sharrmapallavii</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sharrmapallavii"/>
    <language>en</language>
    <item>
      <title>Introducing multi_select_flutter_custom: A Customizable Multi-Select Widget for Flutter Apps</title>
      <dc:creator>Pallavii Sharrma</dc:creator>
      <pubDate>Tue, 08 Jul 2025 11:04:13 +0000</pubDate>
      <link>https://dev.to/sharrmapallavii/introducing-multiselectfluttercustom-a-customizable-multi-select-widget-for-flutter-apps-3gmb</link>
      <guid>https://dev.to/sharrmapallavii/introducing-multiselectfluttercustom-a-customizable-multi-select-widget-for-flutter-apps-3gmb</guid>
      <description>&lt;p&gt;⚫ Introduction&lt;br&gt;
While working on complex Flutter UI forms, I often found limitations in existing multi-select widgets — especially when it came to customization and styling. That's what inspired me to build multi_select_flutter_custom — a lightweight, fully customizable multi-select widget for Flutter.&lt;/p&gt;

&lt;p&gt;This plugin allows developers to easily integrate a beautiful and flexible multi-select dropdown or dialog in their Flutter apps with minimal configuration.&lt;/p&gt;

&lt;p&gt;⚫ Features&lt;br&gt;
✅ Fully customizable UI&lt;br&gt;
✅ Works with any data type using generics&lt;br&gt;
✅ Supports chips, dropdowns, and dialogs&lt;br&gt;
✅ Easy-to-use API similar to multi_select_flutter, but with better customization&lt;br&gt;
✅ Null safety support&lt;/p&gt;

&lt;p&gt;`⚫ &lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
Add this to your pubspec.yaml:&lt;/p&gt;

&lt;p&gt;dependencies:&lt;br&gt;
  multi_select_flutter_custom: ^&lt;br&gt;
Then run:&lt;/p&gt;

&lt;p&gt;flutter pub get`&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;How to Use&lt;/strong&gt;&lt;br&gt;
Here's a quick example of how to use it:&lt;/p&gt;

&lt;p&gt;`&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
MultiSelectCustomBottomSheetField&amp;lt;String&amp;gt;(&lt;br&gt;
  items: ['Apple', 'Banana', 'Mango']&lt;br&gt;
      .map((e) =&amp;gt; MultiSelectCustomItem&amp;lt;String&amp;gt;(value: e, label: e))&lt;br&gt;
      .toList(),&lt;br&gt;
  onConfirm: (values) {&lt;br&gt;
    print("Selected values: $values");&lt;br&gt;
  },&lt;br&gt;
  title: const Text("Select Fruits"),&lt;br&gt;
)&lt;br&gt;
🔧 You can also create your own custom itemBuilder or use chip display widgets.&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Customization&lt;/strong&gt;&lt;br&gt;
You can customize the:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Dialog style&lt;/li&gt;
&lt;li&gt;Title widget&lt;/li&gt;
&lt;li&gt;Item builder&lt;/li&gt;
&lt;li&gt;Confirmation buttons&lt;/li&gt;
&lt;li&gt;Chip display&lt;/li&gt;
&lt;li&gt;Selected item styling&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Example with chips:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;MultiSelectCustomChipDisplay&amp;lt;String&amp;gt;(&lt;br&gt;
  items: selectedItems.map((e) =&amp;gt; MultiSelectCustomItem(value: e, label: e)).toList(),&lt;br&gt;
)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Use Cases&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tag selection&lt;br&gt;
Filter dropdowns&lt;br&gt;
User roles or categories&lt;br&gt;
Multi-select search input&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;⚫ &lt;strong&gt;Why I Built This&lt;/strong&gt;&lt;br&gt;
Most of the popular packages like multi_select_flutter are great, but they often fall short when full visual customization is needed. I wanted something reusable and developer-friendly — so I built this with flexibility and simplicity in mind.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>ui</category>
    </item>
    <item>
      <title>How I Fetched GPS Time in Flutter Using Platform Channels (Android + iOS)</title>
      <dc:creator>Pallavii Sharrma</dc:creator>
      <pubDate>Tue, 08 Jul 2025 10:27:55 +0000</pubDate>
      <link>https://dev.to/sharrmapallavii/how-i-fetched-gps-time-in-flutter-using-platform-channels-android-ios-1mcm</link>
      <guid>https://dev.to/sharrmapallavii/how-i-fetched-gps-time-in-flutter-using-platform-channels-android-ios-1mcm</guid>
      <description>&lt;p&gt;In mobile apps where time is critical (like attendance systems, time tracking, etc.), relying on the device clock can be risky. Users can manually change their device time to manipulate records — which defeats the purpose of accurate logs.&lt;/p&gt;

&lt;p&gt;To solve this, I implemented a solution in Flutter using Platform Channels to fetch GPS time directly from the device hardware (Android and iOS), bypassing the local clock.&lt;/p&gt;

&lt;p&gt;Let me walk you through why this is useful, and how I built it.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;The Problem With DateTime.now()&lt;/strong&gt;&lt;br&gt;
In Flutter, when you use DateTime.now(), it fetches the current time based on the user's device clock. This means:&lt;/p&gt;

&lt;p&gt;The time can be manipulated by changing the phone's settings.&lt;br&gt;
If your app relies on time integrity, this opens a loophole.&lt;br&gt;
Example use-cases affected:&lt;/p&gt;

&lt;p&gt;Attendance apps&lt;br&gt;
Time-sensitive transactions&lt;br&gt;
Geo-tagged activities&lt;/p&gt;

&lt;p&gt;Even alternatives like NTP (network time) require an internet connection, which may not always be available.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Why GPS Time Is More Reliable&lt;/strong&gt;&lt;br&gt;
Every GPS satellite broadcasts a precise timestamp derived from atomic clocks. Mobile devices, when fetching location data from GPS, also receive this exact time.&lt;/p&gt;

&lt;p&gt;This time cannot be changed by the user.&lt;br&gt;
It doesn’t need internet.&lt;br&gt;
It's highly accurate (in milliseconds).&lt;br&gt;
This makes GPS time ideal for trusted timestamps.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Solution: Use Platform Channels in Flutter&lt;/strong&gt;&lt;br&gt;
Since Flutter does not expose GPS timestamp directly via Dart APIs, I used platform channels to execute native code (Java/Kotlin for Android, Swift for iOS) and fetch the time.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Architecture&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Flutter (Dart)&lt;br&gt;
   ↓&lt;br&gt;
Platform Channel&lt;br&gt;
   ↓&lt;br&gt;
Native Code (Android/iOS)&lt;br&gt;
   ↓&lt;br&gt;
Get GPS Timestamp&lt;br&gt;
   ↓&lt;br&gt;
Return to Flutter&lt;br&gt;
⚫ &lt;strong&gt;Android Native Code (Kotlin)&lt;/strong&gt;&lt;br&gt;
On Android, I used LocationManager with GPS_PROVIDER. Here's the Kotlin code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private fun getGpsTime(result: MethodChannel.Result) {
    val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        result.error("PERMISSION_DENIED", "Location permission not granted", null)
        return
    }

    val provider = LocationManager.GPS_PROVIDER
    val location = locationManager.getLastKnownLocation(provider)
    if (location != null) {
        result.success(location.time)  // GPS time in milliseconds
    } else {
        result.error("NO_LOCATION", "Location is null", null)
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚫ &lt;strong&gt;Permission needed: ACCESS_FINE_LOCATION&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure to request runtime permissions and handle GPS being disabled.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;iOS Native Code (Swift)&lt;/strong&gt;&lt;br&gt;
On iOS, I used CLLocationManager and accessed the timestamp from the location object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func getGpsTime(result: @escaping FlutterResult) {
    let locationManager = CLLocationManager()
    locationManager.requestWhenInUseAuthorization()

    if CLLocationManager.locationServicesEnabled() {
        locationManager.requestLocation()
        if let location = locationManager.location {
            let gpsTime = location.timestamp.timeIntervalSince1970 * 1000
            result(Int(gpsTime))
        } else {
            result(FlutterError(code: "NO_LOCATION", message: "Location is null", details: nil))
        }
    } else {
        result(FlutterError(code: "GPS_DISABLED", message: "Location services are disabled", details: nil))
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚫ &lt;strong&gt;Update your Info.plist with&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;key&amp;gt;NSLocationWhenInUseUsageDescription&amp;lt;/key&amp;gt;&lt;br&gt;
&amp;lt;string&amp;gt;This app uses your location to fetch accurate GPS time.&amp;lt;/string&amp;gt;&lt;br&gt;
🔁 Flutter Side: MethodChannel Code&lt;br&gt;
In your Dart code, use a MethodChannel to call platform-specific functions.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;static const platform = MethodChannel('com.example.gps_time');

Future&amp;lt;DateTime?&amp;gt; getGpsTime() async {
  try {
    final int gpsTimeMillis = await platform.invokeMethod('getGpsTime');
    return DateTime.fromMillisecondsSinceEpoch(gpsTimeMillis);
  } catch (e) {
    print("Error fetching GPS time: $e");
    return null;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to initialize the channel in your MainActivity (Android) and AppDelegate (iOS) files.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Testing and Results&lt;/strong&gt;&lt;br&gt;
I manually tested this by:&lt;br&gt;
Changing system time to a wrong value.&lt;br&gt;
Fetching GPS time via platform channel.&lt;/p&gt;

&lt;p&gt;⚫ Result: The GPS time stayed accurate and unaffected by device time changes.&lt;br&gt;
In offline mode too, as long as the GPS was available, I could fetch correct time.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Challenges Faced&lt;/strong&gt;&lt;br&gt;
GPS takes time to get a fix; sometimes the location is null.&lt;br&gt;
iOS requires location permission and simulator doesn't return real GPS time.&lt;br&gt;
Cold starts need fallback/retries until location is ready.&lt;/p&gt;

&lt;p&gt;⚫ &lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Using platform channels to fetch GPS-based time in Flutter is an excellent way to ensure tamper-proof timestamps in your app. You can combine this with your backend or logs to increase trust and prevent misuse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If your app uses time as a critical value — never rely on DateTime.now() alone.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>learning</category>
      <category>flutter</category>
    </item>
  </channel>
</rss>
