2021/5/21 : Flutter : Extract Flutter Widgetを使おう

null-safety-article

 

(1)まずシンプルな例から。

//(1)Extract前(簡単バージョン)
import 'package:flutter/material.dart';
void main(){
  runApp(MaterialApp(home:MyApp(),),);
}
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar:AppBar(title:const Text('title'),),
      body: Container(
        color:Colors.green,
        child:Column(
          children:const [
            Card(
              child:Text("first card"),
            ),
            Card(
              child:Text("second card"),
            ),
          ],
        ),