Skip to content

Instantly share code, notes, and snippets.

@cnruby
Created December 7, 2019 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnruby/ab7d34cbcff1445e2178ded018c08083 to your computer and use it in GitHub Desktop.
Save cnruby/ab7d34cbcff1445e2178ded018c08083 to your computer and use it in GitHub Desktop.
Flutter App 33: Add an text input field
import 'package:flutter/material.dart';
void main() {
runApp(new FriendlychatApp());
}
class FriendlychatApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "Friendlychat",
home: new ChatScreen(),
);
}
}
class ChatScreen extends StatefulWidget {
@override
State createState() => new ChatScreenState();
}
class ChatScreenState extends State<ChatScreen> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text("Friendlychat")),
body: _buildTextComposer(),
);
}
Widget _buildTextComposer() {
return new Container(
margin: const EdgeInsets.symmetric(horizontal: 20.0),
child: new TextField(
decoration: new InputDecoration.collapsed(hintText: "Send a message"),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment