Flutter Dart Convert String Text To Upper Case Lower Case Example

In Dart there are two inbuilt functions available to convert any type of string text to lower case and upper case using String.toLowerCase() and String.toUpperCase() function. These functions would directly apply on String and convert them to upper case and Lower case. In this tutorial we would create 2 functions to convert string to lower case and upper case. We would call these functions on Button onPress event. We would use State to show the changes on application run time on mobile screen. So in this tutorial we would Flutter Dart Convert String Text To Upper Case Lower Case Android iOS Example Tutorial.

Contents in this project Flutter Flutter Dart Convert String Text To Upper Case Lower Case Android iOS Example Tutorial:

1. Import material.dart package in your app’s main.dart file.

2. Creating void main runApp() method and here we would call our main MyApp class.

3. Creating our main Root parent class named as MyApp extends StatelessWidget. In this class we would call our NextWidget class.

4. Creating another class named as NextWidget extends StatefulWidget. In this class we would make the createState() method of State and pass NextState class name along with it to make the mutable state in given class.

5. Creating or main Child class named as NextState extends State.

6. Creating a String data type named as output with some random text string. We would convert this string to upper case and lower case.

7. Creating a function named as convertToLowerCase() and convertToUpperCase() to make the Text into upper case and Lower case using String.toLowerCase() and String.toUpperCase() function.

8. Creating Widget Build Area -> Column widget -> Text widget and 2 Raised Button widgets. We would call both above functions on button onPress event.

9. Complete source code for main.dart file:

Screenshots:

Flutter Dart Convert String Text To Upper Case Lower Case Example Flutter Dart Convert String Text To Upper Case Lower Case Example

Leave a Reply

Your email address will not be published. Required fields are marked *