ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 공용 위젯 파일 샘플.. 이런 구성과 이런 형태로 간단한 위젯 공급하면 어떨지..
    카테고리 없음 2023. 8. 4. 00:49
    // Copyright 2022 The Flutter Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.

    import 'package:flutter/material.dart';

    class Header extends StatelessWidget {
    const Header(this.heading, {super.key});
    final String heading;

    @override
    Widget build(BuildContext context) => Padding(
    padding: const EdgeInsets.all(8.0),
    child: Text(
    heading,
    style: const TextStyle(fontSize: 24),
    ),
    );
    }

    class Paragraph extends StatelessWidget {
    const Paragraph(this.content, {super.key});
    final String content;
    @override
    Widget build(BuildContext context) => Padding(
    padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
    child: Text(
    content,
    style: const TextStyle(fontSize: 18),
    ),
    );
    }

    class IconAndDetail extends StatelessWidget {
    const IconAndDetail(this.icon, this.detail, {super.key});
    final IconData icon;
    final String detail;

    @override
    Widget build(BuildContext context) => Padding(
    padding: const EdgeInsets.all(8.0),
    child: Row(
    children: [
    Icon(icon),
    const SizedBox(width: 8),
    Text(
    detail,
    style: const TextStyle(fontSize: 18),
    )
    ],
    ),
    );
    }

    class StyledButton extends StatelessWidget {
    const StyledButton({required this.child, required this.onPressed, super.key});
    final Widget child;
    final void Function() onPressed;

    @override
    Widget build(BuildContext context) => OutlinedButton(
    style: OutlinedButton.styleFrom(
    side: const BorderSide(color: Colors.deepPurple)),
    onPressed: onPressed,
    child: child,
    );
    }
Designed by Tistory.