【flutter】TextFieldなどのUI

class _MyHomePageState extends State<MyHomePage> {

  static var _message = "ok.";
  static final _controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('App Name'),
      ),
      body:
      new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(20.0),
              child: Text(
                _message,
                style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w400,
                  fontFamily:"Robot"),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(10.0),
              child: TextField(
                controller: _controller,
                style: TextStyle(
                    fontSize: 28.0,
                    color: const Color(0xffFF0000),
                    fontWeight: FontWeight.w400,
                    fontFamily:"Robot"),
              ),
            ),
              ElevatedButton(
                onPressed: buttonPressed,
                child: Text(
                  "Push me!",
                  style: TextStyle(
                    fontSize: 32.0,
                    color: const Color(0xff000000),
                    fontWeight: FontWeight.w400,
                    fontFamily: "Robot"),
              ),
            )
          ]
        ),

      ),

    );
  }

  void buttonPressed(){
    setState((){
      _message = "you said : " + _controller.text;
    });
  }
}
class _MyHomePageState extends State<MyHomePage> {

  static var _message = "ok.";
  static final _controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('App Name'),
      ),
      body:
      new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(20.0),
              child: Text(
                _message,
                style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w400,
                  fontFamily:"Robot"),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(10.0),
              child: TextField(
                onChanged: textChanged,
                controller: _controller,
                style: TextStyle(
                    fontSize: 28.0,
                    color: const Color(0xffFF0000),
                    fontWeight: FontWeight.w400,
                    fontFamily:"Robot"),
              ),
            ),
          ]
        ),

      ),

    );
  }

  void textChanged(String val){
    setState((){
      _message = val.toUpperCase();
    });
  }
}

checkbox

class _MyHomePageState extends State<MyHomePage> {

  static var _message = "ok.";
  static var _checked = false;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('App Name'),
      ),
      body:
      new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(20.0),
              child: Text(
                _message,
                style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w400,
                  fontFamily:"Robot"),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(10.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.start,
                mainAxisSize: MainAxisSize.max,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: <Widget> [
                  Checkbox(
                    value:_checked,
                    onChanged: checkChanged,
                  ),
                  Text(
                    "Checkbox",
                    style: TextStyle(fontSize:28.0,
                    fontWeight: FontWeight.w400,
                    fontFamily: "Roboto"),
                  )
                ]
              )
            ),
          ]
        ),

      ),

    );
  }

  void checkChanged(bool? value){
    setState((){
      _checked = value!;
      _message = value ? 'checked!' : 'not checked...';
    });
  }
}

Radio

class _MyHomePageState extends State<MyHomePage> {

  static var _message = "ok.";
  static var _selected = 'A';

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('App Name'),
      ),
      body:
      new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(20.0),
              child: Text(
                _message,
                style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w400,
                  fontFamily:"Robot"),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(10.0),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              mainAxisSize: MainAxisSize.max,
              crossAxisAlignment:CrossAxisAlignment.center,
              children: <Widget>[
                Radio<String>(
                  value: 'A',
                  groupValue: _selected,
                  onChanged: checkChanged,
                ),
                Text(
                  "radio A",
                  style: TextStyle(fontSize:28.0,
                  fontWeight: FontWeight.w400,
                  fontFamily: "Roboto"),
                )
              ]
            ),
            Row(
                mainAxisAlignment: MainAxisAlignment.start,
                mainAxisSize: MainAxisSize.max,
                crossAxisAlignment:CrossAxisAlignment.center,
                children: <Widget>[
                  Radio<String>(
                    value: 'B',
                    groupValue: _selected,
                    onChanged: checkChanged,
                  ),
                  Text(
                    "radio B",
                    style: TextStyle(fontSize:28.0,
                        fontWeight: FontWeight.w400,
                        fontFamily: "Roboto"),
                  )
                ]
            )
          ]
        ),

      ),

    );
  }

  void checkChanged(String? value){
    setState((){
      _selected = value ?? 'nodata';
      _message = 'select: $_selected';
    });
  }
}

DropdownButton

class _MyHomePageState extends State<MyHomePage> {

  static var _message = "ok.";
  static var _selected = 'One';

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('App Name'),
      ),
      body:
      new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(20.0),
              child: Text(
                _message,
                style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w400,
                  fontFamily:"Robot"),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(10.0),
            ),
            DropdownButton<String>(
              onChanged: popupSelected,
              value: _selected,
              style: TextStyle(color:Colors.black,
                fontSize:28.0,
                fontWeight:FontWeight.w400,
                fontFamily: 'Robot'),

              items: <DropdownMenuItem<String>>[
                const DropdownMenuItem<String>(value: 'One', child: const Text('One')),
                const DropdownMenuItem<String>(value: 'Two', child: const Text('Two')),
                const DropdownMenuItem<String>(value: 'Three', child: const Text('Three')),
              ]
            )
          ]
        ),

      ),

    );
  }

  void popupSelected(String? value){
    setState((){
      _selected = value ?? 'not selected...';
      _message = 'select: $_selected';
    });
  }
}class _MyHomePageState extends State<MyHomePage> {

  static var _message = "ok.";
  static var _selected = 'One';

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('App Name'),
      ),
      body:
      new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.all(20.0),
              child: Text(
                _message,
                style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w400,
                  fontFamily:"Robot"),
              ),
            ),
            Padding(
              padding: EdgeInsets.all(10.0),
            ),
            DropdownButton<String>(
              onChanged: popupSelected,
              value: _selected,
              style: TextStyle(color:Colors.black,
                fontSize:28.0,
                fontWeight:FontWeight.w400,
                fontFamily: 'Robot'),

              items: <DropdownMenuItem<String>>[
                const DropdownMenuItem<String>(value: 'One', child: const Text('One')),
                const DropdownMenuItem<String>(value: 'Two', child: const Text('Two')),
                const DropdownMenuItem<String>(value: 'Three', child: const Text('Three')),
              ]
            )
          ]
        ),

      ),

    );
  }

  void popupSelected(String? value){
    setState((){
      _selected = value ?? 'not selected...';
      _message = 'select: $_selected';
    });
  }
}