How to implement persistent storage in swiftUI?

By | February 17, 2025

There are multiple ways to implement persistent storage in SwiftUI, including the key property wrappers for state management. Let me explain the key concepts demonstrated in this implementation: 1. @ObservableObject & @Published 2. @StateObject & @EnvironmentObject 3. Persistent Storage Implementation 4. Data Flow This implementation provides several benefits: Thank you for reading!

What are the built in shapes in swiftUI and how to use them?

By | February 8, 2025

SwiftUI supports some in-built shapes that are used to develop a custom design and user interface component. These shapes are easy to use and can customized in various style, colors, fills, transformations, etc.  2. Rectangle 3. Rounded Rectangle. SwiftUI also provide built-in RoundedRectangle() to create a rounded rectangle shape. The rounded rectangle is a very useful shape… Read More »

How different is swiftUI with respect to UIKit?

By | February 7, 2025

SwiftUI and UIKit are both iOS development frameworks, but they differ significantly: SwiftUI: Declarative UI design UIKit: Imperative UI construction 2. Code Complexity SwiftUI: Shorter, more readable code UIKit: More verbose, requires more manual configuration 3. Layout Approach SwiftUI: Uses modern compositional layouts with stacks and modifiers UIKit: Relies on Auto Layout and frame-based positioning… Read More »

How multi threading and concurrency is achieved in SwiftUI ?

By | February 5, 2025

SwiftUI handles concurrency and multithreading primarily through Swift’s native concurrency features and some SwiftUI-specific patterns. Here’s a comprehensive breakdown: These concurrency features are designed to work together seamlessly with SwiftUI’s declarative nature, ensuring that: The key is that SwiftUI abstracts away much of the complexity of traditional multithreading while providing powerful tools for handling asynchronous… Read More »

How to use GeometryReader for containing one view in another in swiftUI?

By | February 3, 2025

There are different ways to limit or constrain a subview within its superview in SwiftUI. ‘GeometryReader’ is one among those for relative sizing of the subviews in a view. We will see different ways of using ‘GeometryReader’ in below examples. 2. CenteredContentExample: 3. ResponsiveContainerExample: 4. ProportionalContainerExample: Key tips for using GeometryReader: a. Always account for… Read More »

Latest changes in swiftUI

By | February 2, 2025

Today we will take you through latest changes apple brought in swiftUI. Let me highlight some of the most significant practical changes that developers should focus on. Latest SwiftUI Changes and Features 1. Layout and View Enhancements New Layout Types Layout Modifiers 2. Data Handling Improvements Observable Pattern Data Flow 3. UI Components and Interactions… Read More »

What “URL encoding” or “percent encoding” is?

By | January 30, 2025

Read about what ‘addingPercentEncoding‘ is and why it’s important in URL handling. addingPercentEncoding(withAllowedCharacters:) is a String method in Swift that encodes special characters in a string to make it URL-safe. This is often called “URL encoding” or “percent encoding.” Let me break this down with examples: Why URL encoding is necessary? Common character encodings: Here’s… Read More »

Read from plist file in iOS / Swift

By | January 29, 2025

What is Plist file? A Property List (Plist) file is a specialized file format used to store structured data. Plist files can contain various data types, including dictionaries, arrays, strings, numbers, dates, and binary data. They are widely used in Apple development for various purposes, such as app configuration, user preferences, and data serialization. Plist files have a .plist file extension and… Read More »

Flutter Best Practices – Part 1

By | January 25, 2025

Video Tutorial Here is the first part of best practices in Flutter… 1. Placeholder Widgets Use SizedBox instead of Container as Placeholder widgets. Take a look at the below use-case The SizedBox is a const constructor and creates a fixed-size box. The width and height parameters can be null to indicate that the size of the box should not… Read More »

Wrap Widget & Chip Widgets in Flutter

By | January 23, 2025

Wrap widget is such a useful widget in many circumstances. Here we will learn about different types of Chip Widgets such as & Wrap Widgets Watch Video Tutorial First Let’s create a simple Chip Widget. Widget chip(String label, Color color) { return Chip( labelPadding: EdgeInsets.all(5.0), avatar: CircleAvatar( backgroundColor: Colors.grey.shade600, child: Text(label[0].toUpperCase()), ), label: Text( label, style:… Read More »

Creating a CarouselView in Flutter

By | January 22, 2025

This post provides a step-by-step guide to implementing a carousel slider in Flutter using a custom CarouselView widget. The code demonstrates how to display a horizontal carousel of images with various customization options. Demo Full code Example import ‘package:flutter/material.dart’;List<String> images = [ “https://images.unsplash.com/photo-1503376780353-7e6692767b70”, “https://images.unsplash.com/photo-1577714141096-bf2b9e69500a”, “https://images.unsplash.com/photo-1542362567-b07e54358753”, “https://images.unsplash.com/photo-1511407397940-d57f68e81203”, “https://images.unsplash.com/photo-1659671026913-b7e632f17395”];class Home extends StatefulWidget { const Home({super.key}); @override State<Home>… Read More »

Comparison of the Latest AI Chat Models in 2024: OpenAI o1, Google Gemini 2.0, xAI Grok-2, Meta Llama 3.3, and Nvidia Nemotron-4 340B

By | December 22, 2024

Feature OpenAI o1 Google Gemini 2.0 xAI Grok-2 Meta Llama 3.3 Nvidia Nemotron-4 340B Developer OpenAI Google xAI (Elon Musk’s startup) Meta Nvidia Release Date December 2024 December 2024 December 2024 December 2024 December 2024 Key Focus Problem-solving, STEM, competitive programming Efficiency, advanced reasoning Integration with X (formerly Twitter) Open research, accessible to developers Open… Read More »

Flutter 3.27 Updates in Brief

By | December 22, 2024

Flutter 3.27, released in December 2024, introduces several enhancements across the framework, engine, and developer tools, aiming to improve performance, user interface components, and the overall development experience. Framework Enhancements: • Cupertino Widget Updates: Significant improvements have been made to Cupertino widgets to better align with iOS design standards: • CupertinoCheckbox and CupertinoRadio: Enhanced sizes,… Read More »

How to Use Streams to Download a File in Flutter

By | December 22, 2024

In Flutter, Streams are a powerful way to handle asynchronous data like file downloads. When downloading a file, streams can help you process chunks of data in real time, making it easy to show progress to the user. Here’s a step-by-step guide on how to download a file using streams in Flutter. Add Required Dependencies… Read More »

How to animate SF symbols?

By | October 24, 2024

SwiftUI provides the symbolEffect() modifier to add built-in animation effects for SF Symbols and produce a real touch of delight with almost no effort. For example, we could animate a dog icon up and down with a gentle bounce whenever a button is pressed. You could also try .pulse to animate the opacity, but where things get really clever is when… Read More »

How to fill and stroke basic shapes in swiftUI?

By | October 9, 2024

In latest iOS versions ( ios 17 onwards) we can directly put stroke and fill shapes just by adding modifiers one after another as shown below. It works with multiple strokes of various sizes as shown below. In older versions of iOS ( iOS 16 ) SwiftUI provides the fill(), stroke(), and strokeBorder() modifiers for adjusting the way we… Read More »

How to display solid shapes in swiftUI?

By | October 6, 2024

Sometimes we need to display basic shapes in our apps just to get more attractive UI or just to highlight something. SwiftUI has several build in shapes to help the user to ease the development. It has several built-in shapes such as rectangles, circles, and capsules, each of which can be created, color, and positioned… Read More »

How to add image as background in swiftUI?

By | October 4, 2024

In swiftUI, apple doesn’t provide any dedicated background image or color modifier. It lets us add any kind of background view using its background() modifier. For example, this creates a text view with a large font, then places a 100×100 image behind it. However, it doesn’t need to be an image all the time. For example, this… Read More »

How to play movies with VideoPlayer

By | September 29, 2024

Playing movie or videos from any source is important when it comes to application development. Apple provides some default frameworks to handle it. SwiftUI’s VideoPlayer view lets us playback movies from any URL, local or remote. It comes from the AVKit framework, this can be added to the framework by importing AVKit. The below example shows how… Read More »