Flutter code from the video
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Hello World'),
centerTitle: true,
titleTextStyle: const TextStyle(
color: Colors.red,
fontSize: 30.0,
),
actions: [
IconButton(
icon: const Icon(Icons.home),
onPressed: () {
print('You clicked the home button');
},
),
IconButton(
icon: const Icon(Icons.camera),
onPressed: () {
print('You clicked the camera button');
},
),
],
shadowColor: Colors.amber,
backgroundColor: Colors.blue, //bgcolor of the AppBar Widget
elevation: 0,
),
//this is to change the background color of the body
backgroundColor: Colors.white,
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.black12,
elevation: 10.0,
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home_filled), label: "Home"),
BottomNavigationBarItem(icon: Icon(Icons.camera), label: "Images"),
BottomNavigationBarItem(icon: Icon(Icons.shop_2), label: "Shop"),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {
print("You clicked the floating actoin button");
},
child: Icon(Icons.add),
backgroundColor: Colors.blue,
),
drawer: Drawer(
child: Column(
children: [
DrawerHeader(
child: ClipRRect(
borderRadius: BorderRadius.circular(150),
child: Image.asset("assets/images/bike.jpg"),
),
),
ListTile(
leading: const Icon(Icons.phone_android),
title: const Text("Contact Us"),
onTap: () {
print("You clicked the Contact Us Menu!");
Navigator.pop(context);
},
),
ListTile(
leading: const Icon(Icons.abc),
title: const Text("Learn ABC"),
onTap: () {
print("You clicked the Alphabet Menu!");
Navigator.pop(context);
},
),
ListTile(
leading: const Icon(Icons.add_comment),
title: const Text("Add Comment"),
onTap: () {
print("You clicked the Add Comment Menu!");
Navigator.pop(context);
},
),
],
),
),
body: Container(
width: 200,
height: 300,
color: Colors.green,
child: Image.network(
"https://docs.flutter.dev/assets/images/dash/dash-fainting.gif",
// color: Colors.red,
// colorBlendMode: BlendMode.colorDodge,
fit: BoxFit.fill,
),
),
);
}
}
No comments:
Post a Comment