Created
June 7, 2020 16:14
-
-
Save sgr-ksmt/737bff1e56c2b79ac2c079900226e3e5 to your computer and use it in GitHub Desktop.
Revisions
-
sgr-ksmt created this gist
Jun 7, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,121 @@ import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Wrap( spacing: 16, runSpacing: 16, children: [ View( title: "Pteranodon", ), View( title: "Cobra", ), View( title: "Mountain Gorilla", ), View( title: "Giraffe", ), View( title: "blue whale", ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } } class View extends StatelessWidget { const View({Key key, this.title}) : super(key: key); final String title; @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, border: Border.all(color: Colors.black45, width: 1), borderRadius: BorderRadius.circular(8.0), ), child: Padding( padding: const EdgeInsets.all(8.0), // POINT: IntrinsicWidthをつかう child: IntrinsicWidth( child: Column( mainAxisSize: MainAxisSize.min, children: [ Text(title), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon(Icons.edit), Icon(Icons.delete), ], ), ], ), ), ), ); } }