Function, Classes, Routes, Theme and Text flutter app
Source code:
main.dart
import 'package:flutter/material.dart';import 'package:myapp/home_page.dart';import 'package:myapp/login_page.dart';void main() {runApp(MyApp());}class MyApp extends StatelessWidget {// const MyApp({Key? key}) : super(key: key);@overrideWidget build(BuildContext context) {return MaterialApp(initialRoute: "/home",routes: {"/": (context) => Loginpage(),"/home": (context) => HomePage(),"/login": (context) => Loginpage()},);}}
home_page.dart
import 'package:flutter/material.dart';class HomePage extends StatelessWidget {const HomePage({Key? key}) : super(key: key);@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text("Catelog App"),),body: Center(child: Container(child: Text("Welcome flutter app"),),),drawer: Drawer(),);}}
login_page.dart
import 'package:flutter/material.dart';class Loginpage extends StatelessWidget {const Loginpage({Key? key}) : super(key: key);@overrideWidget build(BuildContext context) {return Material(child: Center(child: Text("Login Page",style: TextStyle(fontSize: 20, color: Colors.blue, fontWeight: FontWeight.bold),textScaleFactor: 2.0,),),);}}
Output
Post a Comment