Advertisement
narimetisaigopi

#11 Material App Scaffold AppBar Container Text FloatingActionButton Widgets

Jun 7th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:my_first_app/home_screen.dart';
  3.  
  4. void main() {
  5. runApp(MyApp());
  6. }
  7.  
  8. class MyApp extends StatelessWidget {
  9. // This widget is the root o.
  10. @override
  11. Widget build(BuildContext context) {
  12. return MaterialApp(
  13. title: 'My App Demo',
  14. theme: ThemeData(
  15. buttonColor: Colors.red,
  16. primarySwatch: Colors.red,
  17. floatingActionButtonTheme:
  18. FloatingActionButtonThemeData(backgroundColor: Colors.green)),
  19. home: HomeScreen(),
  20. );
  21. }
  22. }
  23.  
  24. class HomeScreen extends StatelessWidget {
  25. @override
  26. Widget build(BuildContext context) {
  27. return Scaffold(
  28. appBar: AppBar(
  29. title: Text("My AppBar"),
  30. centerTitle: true,
  31. ),
  32. body: Center(
  33. child: Container(
  34. // child: Text(
  35. // "Hello World",
  36. // style: TextStyle(
  37. // fontSize: 32,
  38. // fontWeight: FontWeight.w400,
  39. // color: Colors.red,
  40. // decoration: TextDecoration.none),
  41. // ),
  42.  
  43. child: Icon(
  44. Icons.accessible_forward,
  45. size: 64,
  46. color: Colors.red,
  47. ),
  48. ),
  49. ),
  50. floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  51. floatingActionButton: FloatingActionButton(
  52. onPressed: () {
  53. print("Added to favourites.");
  54. },
  55. backgroundColor: Colors.yellow,
  56. child: Icon(
  57. Icons.favorite,
  58. color: Colors.white,
  59. ),
  60. ),
  61. );
  62. }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement