Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //6.Designing The Mobile app to implement theming and styling
- import 'package:flutter/material.dart';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Network Image',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(),
- debugShowCheckedModeBanner: false,
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- / Design of the application
- appBar: AppBar(
- title: const Text("GeeksforGeeks"),
- backgroundColor: Colors.green,
- ),
- body: Padding(
- padding: const EdgeInsets.all(8.0),
- child: ListView(
- children: <Widget>[
- Padding(
- padding: const EdgeInsets.all(8.0),
- // Image.network(src)
- child: Image.network(
- "https://images.unsplash.com/photo-1584395630820-26d8c2ab3d8e",
- loadingBuilder: (context, child, loadingProgress) {
- if (loadingProgress == null) {
- return child;
- } else {
- return const Center(child: CircularProgressIndicator());
- }
- },
- errorBuilder: (context, error, stackTrace) {
- return const Center(
- child: Text("Failed to load image"),
- );
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Image.network(
- "https://images.unsplash.com/photo-1511765224389-37f0e77cf0eb",
- loadingBuilder: (context, child, loadingProgress) {
- if (loadingProgress == null) {
- return child;
- } else {
- return const Center(child: CircularProgressIndicator());
- }
- },
- errorBuilder: (context, error, stackTrace) {
- return const Center(
- child: Text("Failed to load image"),
- );
- },
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Image.network(
- "https://images.unsplash.com/photo-1593642633279-1796119d5482",
- loadingBuilder: (context, child, loadingProgress) {
- if (loadingProgress == null) {
- return child;
- } else {
- return const Center(child: CircularProgressIndicator());
- }
- },
- errorBuilder: (context, error, stackTrace) {
- return const Center(
- child: Text("Failed to load image"),
- );
- },
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment