Dart tutorial examples/ Flutter By Examples
This is a home page of Dart tutorials and examples.
Dart by examples
- Private Constructor
- Multiple Constructor
- Private variables
- Round double with limit
- Dynamic vs Object
- Check Dart and Flutter Version
- Get Hostname
- initialize final variable
- Round to decimal places
- Phone number validation
- Setter and Getter
- Delay Code execution
- Email validation
- Difference between var,final and dynamic
- Difference between const and final
- Singleton Design pattern
- Generate UUID
- Custom exception and handles it
- Measure elapsed time execution of a function
The following examples categorized based on feature
Operators
Operators are used to apply on operands.
Primitive Types
- Check Integer is whole number or not
- Integer Division
- Integer Length
- Number of digits in a number
- Generate Random Number
Strings
String is an immutable object that contains group of characters enclosed in double quotes.
- Future of String to or from String
- Append Strings
- Capitalize first letter of a string
- Check String contains alphabetic or number
- String encode and decode
- String equal or not
- Get First,Last letter of a string
- String replace method
- String reverse
- String into Array
- Trim space in a string
- Check given variable is a string
- Generate Random String
- Print Dollar to a String
- String empty or null check
- String is numeric or not
Conversion programs
- Convert Int to Double viceversa
- Parse double to/from string
- Convert String to/from Int
- Decimal to/from Binary
- Decimal to hexa number
- Decimal to Octal number
Date and time code
- Convert String to Datetime
- Difference between two dates
- Compare two dates
- Current Date and time
- Current Epoch unix timestamp
- Add/Substract years,days,months hours to Current Date
- Dispay greeting message based on time of the day
- Find Last day of week,month,year
- Display Name of the week
- Check Leap year or not
- Dart timer delay
- Convert 24 hours to 12 hours timestamp
- Convert timestamp to Datetime
- Number of days between two dates
Function
Arrays programs
Array is a group of same data type with fixed size.
List
List is a group of same data type with dynamic size and elements are in insertion order, allow duplicates
- Duplicate list remove
- Immutable List
- Add an element to List at beginning
- Check sublist contains in a List
- List clone example
- Create an empty List
- Convert List of Dynamic to List of String
- List check for empty or null
- Compare two List equal or not
- List filter example
- Flatten a List
- Get First,Last element from a List
- Convert List to Map
- Remove element from a List
- Convert List to Set or viceversa
- Convert List of String to List of numbers
- Convert List to String
- Check variable type is a List
- Difference in List
- Convert FutureList to List
- multiple ways to iterate a List
- Add leading trailing zeroes to number
- Maximum and Minimum from a List
- Create Sequence of numbers
- Sort List of objects in ascending and descending
- Sort List of primitive types
Map, HashMap
Map is a datastructure with key and value pair of elements
- Create an Empty Map
- Check Map is empty or not
- Compare Map equal
- Convert Map to List of Objects
- Check Map is null or not
- Sort Map key and values
- Generate Query String from an Map
Set
Set is a group of same data type with dynamic size and elements are in unordered, does not allow duplicates.
Objects
Enum constants conversions programs
- Convert Enum to Integer
- Convert Enum to String
- Add methods, values using Enum Extension
- Enum comparison operator
- Loop Enum and convert to/from index