Advertisement
rajath_pai

ninja8

Jul 29th, 2021
1,166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.03 KB | None | 0 0
  1. //Learning how to use NetworkImage() to load images
  2.  
  3. import 'package:flutter/material.dart';
  4.  
  5. void main() => runApp(MaterialApp(
  6.       home: Home(),
  7.     ));
  8.  
  9. //StatelessWidget => cannot change over time -> its constant
  10. //why @override ? => beacuse StatelessWidget has it's own build function, as we want to write out own build func, we override it
  11. class Home extends StatelessWidget {
  12.   @override
  13.   Widget build(BuildContext context) {
  14.     return Scaffold(
  15.       appBar: AppBar(
  16.         title: Text(
  17.           'App bar',
  18.           style: TextStyle(color: Colors.white),
  19.         ),
  20.         centerTitle: true,
  21.         backgroundColor: Colors.red,
  22.       ),
  23.       body: Center(
  24.         child: Image(
  25.           image : NetworkImage('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5fekdY7QzAbN4Dvy_xIJHUbiyBNXn3qvUIw&usqp=CAU'),
  26.         ),
  27.       ),
  28.       floatingActionButton: FloatingActionButton(
  29.         child: Text('click me'),
  30.         onPressed: null,
  31.         backgroundColor: Colors.red,
  32.       ),
  33.     );
  34.   }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement