2017-05-30 5 views
0

このチュートリアルの後にはhttps://codelabs.developers.google.com/codelabs/flutter/index.html#4に従っていますが、アプリを実行した後で入力ウィジェットは表示されません。Flutterアプリケーションの入力が見えない

enter image description here

main.dart

import 'package:flutter/material.dart'; 

void main() { 
    runApp(new MaterialApp(
     title: "Friendlychat", 
     home: new Scaffold(
      appBar: new AppBar(
       title: new Text("Friendlychat") 
      ) 
     ) 
    )); 
} 

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> { 

    final TextEditingController _textController = new TextEditingController(); 

    @override 
    Widget build(BuildContext context) { 
     return new Scaffold(
      appBar: new AppBar(
       title: new Text("Friendlychat") 
      ), 
      body: _buildTextComposer() 
     ); 
    } 

    Widget _buildTextComposer() { 
     return new IconTheme(
      data: new IconThemeData(color: Theme 
       .of(context) 
       .accentColor), 
      child: new Container(
       margin: const EdgeInsets.symmetric(horizontal: 8.0), 
       child: new Row(
        children: <Widget>[ 
         new Flexible(
          child: new TextField(
           controller: _textController, 
           onSubmitted: _handleSubmitted, 
           decoration: new InputDecoration.collapsed(
            hintText: "Send a message"), 
          ), 
         ), 
         new Container(
          margin: new EdgeInsets.symmetric(horizontal: 4.0), 
          child: new IconButton(
           icon: new Icon(Icons.send), 
           onPressed:() => 
            _handleSubmitted(_textController.text)), 
         ), 
        ] 
       ), 
      ) 
     ); 
    } 

    void _handleSubmitted(String text) { 
     _textController.clear(); 
    } 
} 

答えて

1

あなたは、前のステップの一部を終了しませんでした。あなたの問題は、このコードにある:

void main() { 
    runApp(new MaterialApp(
    title: "Friendlychat", 
    home: new Scaffold(
     appBar: new AppBar(
     title: new Text("Friendlychat") 
    ) 
    ) 
)); 
} 

あなたはこれでそれを置き換える必要があります。

void main() { 
    runApp(new FriendlyChatApp()); 
} 
関連する問題