Flutter Assignment 04
Flutter Assignment 04
Code:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
OUTPUT:
QUES-2: Modify the previous app to use named routes instead of
MaterialPageRoute. Define named routes for HomeScreen and
DetailsScreen in the MaterialApp widget and navigate between
them using Navigator.pushNamed()
CODE:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
OUTPUT:
QUES-3: Pass data from HomeScreen to DetailsScreen. Add a
button on HomeScreen that navigates to DetailsScreen and
displays a specific message passed as a parameter.
Display the message on DetailsScreen.
CODE:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
return Scaffold(
appBar: AppBar(
title: Text('Details Screen'),
),
body: Center(
child: Text(message),
),
);
}
}
OUPUT:
QUES-4:Create a Flutter app with nested routing. Design a main
screen containing a bottom navigation bar with multiple tabs.
Implement routing for each tab to display different
content using nested Navigator widgets.
CODE:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Nested Routing Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MainScreen(),
);
}
}
DetailScreen(this.detail);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Detail'),
),
body: Center(
child: Text(detail),
),
);
}
}
OUTPUT: