2026.04.26 dart  
 2026.04.26 dart  
 2026.04.25 dart  
 2026.04.19 dart  
 2026.04.19 dart  
 2026.04.19 dart  
 2026.04.15 未分類  

Custom-class


import 'package:flutter/material.dart';

void main() {
  runApp(
   const Column(
    children: [
   AnimalView(
     text: 'mouse',
     color: Colors.yellow,
   ),
   AnimalView(
     text: 'lizard',
     color: Colors.red,
     ),
    ],
  ),
 );
}

class AnimalView extends StatelessWidget {
  const AnimalView({super.key, required this.text, required this.color});
  final String text;
  final Color color;
 @override
 Widget build(BuildContext context) {
  return Container(
  color: color,
  width: 100,
  height: 100,
  child: Center(
   child: Text(
   text,
   textDirection: TextDirection.ltr,
  ),
 ),
 );
}
}
カテゴリー: dart