Flutter Routes and Navigation in Sinhala

Flutter Routes and Navigation in Sinhala

Route: යෙදුම් නව ප්රවණතාවයයි. වර්තමානයේ Play Store හි ඇති යෙදුම් ගණන බොහෝය. යෙදුම් ඒවායේ අන්තර්ගතය පිටු හෝ තිර ලෙස හඳුන්වන සම්පූර්ණ තිර බහාලුමක සංදර්ශන කරයි. flutter දී, පිටු හෝ තිර මාර්ග ලෙස හැඳින්වේ. android වලදී, මෙම පිටු/තිර ක්‍රියාකාරකම් ලෙසත්, iOS හි එය ViewController ලෙසත් හැඳින්වේ. නමුත්, flutter එකකදී, මාර්ග විජට් ලෙස හැඳින්වේ. Flutter හි, පිටුවක් / තිරයක් මාර්ගයක් ලෙස හැඳින්වේ.

Creating routes: A route can be written in the form of a “Class” in Dart using object-oriented concepts. Each route can be written as a separate class and has its own contents and UI.

Now let’s create two routes, each having unique App Bars and Raised Buttons. The code is as follows:

 

class HomeRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
    return Scaffold(
    appBar: AppBar(
        title: Text('Apps Lanka Dev'),
        backgroundColor: Colors.green,
    ),
    body: Center(
        child:elevatedButton(
        child: Text('Click Me!'),
        onPressed: () {
            
            // Contains the code that helps us
            // navigate to the second route.
MaterialPageRoute(builder: (context) => const SecondRoute()),
        },
        ),
    ),
    );
}
}

class SecondRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
    return Scaffold(
    appBar: AppBar(
        title: Text("Click Me Page"),
        backgroundColor: Colors.green,
    ),
    body: Center(
        child: elevatedButton(
        onPressed: () {
            
            // Contains the code that helps us
             Navigator.pop(context);
        },
        child: Text('Home!'),
        ),
    ),
    );
}
}

 

 

Navigator: නමට අනුව, Navigator යනු මාර්ග අතර සැරිසැරීමට උපකාරී වන විජට් එකකි. මාර්ග සමඟ ගනුදෙනු කිරීමේදී නාවිකයා ස්ටැක් ක්‍රමය අනුගමනය කරයි. පරිශීලකයා විසින් කරන ලද ක්‍රියා මත පදනම්ව, මාර්ග එකිනෙක ගොඩගැසී ඇති අතර ආපසු එබූ විට, එය මෑතදී පැමිණි මාර්ගයට යයි. Navigator යනු අට්ටි විනයක් අනුගමනය කරන විජට් එකකි.

 

 


 We are developing Mobile application and Web application for more details visit our web site www.appslanka.lk

0 Comments

Leave a comment

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