3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

flutterで画像サムネイル付きリストを表示

Posted at

やりたいこと

画像サムネイル付きリストを表示させたい。
(リストの各項目の左端に写真が表示される)。

image.png

画像データの取得

https://qiita.com/kenichiro-yamato/items/83c508d24de9d588da07
を参照。

完成形 main.dart


import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Icons List',
      theme: ThemeData(
        primarySwatch: Colors.pink,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: '写真サムネイル付きリスト'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: 
      ListView(
        children: <Widget>[
          ListTile(
            leading: Image.network('https://www.listofdownload.com/wp-content/uploads/2018/11/Marvels-Spider-Man-4K-Wallpaper-3840x2160.jpg', width: 70,),
            title: Text("スパイダーマン"),
            ),
          ListTile(
            leading: Image.network('https://sce.scene7.com/is/image/playstation/pljm16288_640x360', width: 70,),
            title: Text("バイオハザード RE:2"),
          ),
          ListTile(
            leading: Image.network('https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRZ6BNGobCtQJC4Pn0qumG3SkbVmbPvbns6-YO3PLI_KhSAfnXz&usqp=CAU', width: 70,),
            title: Text("ファイナルファンタジー7リメイク"),
          ),
        ],
      ),
    );
  }
}

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?