載入遠端圖片

飞雪飘鸿發表於2024-08-20
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
        appBar: AppBar(title: const Text("載入遠端圖片")), body: const MyApp()),
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 300,
        height: 160,
        decoration: const BoxDecoration(color: Colors.lightBlue),
        child: Image.network(
          "https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1p2dXL.img?w=768&h=647&m=6&x=358&y=143&s=406&d=406",
          fit: BoxFit.cover,
        ),
      ),
    );
  }
}

  

相關文章