Flutter 我无法修复项目中的按钮

Flutter 我无法修复项目中的按钮,flutter,button,Flutter,Button,我正在开发一个带有颤振的应用程序。但我无法修复项目中的按钮。在我的聊天页面上,按钮向上。我不熟悉颤振语,你能帮我吗 您好,我正在用flutter开发一个应用程序。但我无法修复项目中的按钮。在我的聊天页面上,按钮向上。我不熟悉颤振语,你能帮我吗 截图: 我的按钮代码: class HomePage extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeS

我正在开发一个带有颤振的应用程序。但我无法修复项目中的按钮。在我的聊天页面上,按钮向上。我不熟悉颤振语,你能帮我吗

您好,我正在用flutter开发一个应用程序。但我无法修复项目中的按钮。在我的聊天页面上,按钮向上。我不熟悉颤振语,你能帮我吗

截图:

我的按钮代码:

class HomePage extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<HomePage> {
  final _scrollController = ScrollController();
  List<TabItem> tabItems = List.of([
    new TabItem(Icons.home, "Anasayfa", Colors.blue),
    new TabItem(Icons.message, "Sohbet Odası", Colors.orange),
    new TabItem(Icons.person, "Profil", Colors.red),
  ]);
  int seciliPozisyon = 0;
  CircularBottomNavigationController _navigationController;

  @override
  void initState() {
    super.initState();
    _navigationController =
        new CircularBottomNavigationController(seciliPozisyon);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.black,
        centerTitle: true,
        title: Text("Crypto App"),
      ),
      body: Stack(
        children: <Widget>[
          Padding(
            child: bodyContainer(),
            padding: EdgeInsets.only(bottom: 60),
          ),
          Align(alignment: Alignment.bottomCenter, child: bottomNav())
        ],
      ),
    );
  }

  Widget bodyContainer() {
    String activeUserId =
        Provider.of<AuthorizationService>(context, listen: false).activeUserId;
    Color selectedColor = tabItems[seciliPozisyon].color;
    switch (seciliPozisyon) {
      case 0:
        return HomeScreen();
        break;
      case 1:
        return FriendlyChatApp();
        break;
      case 2:
        return Profile(
          profileId: activeUserId,
        );
        break;
    }
  }

  Widget bottomNav() {
    return CircularBottomNavigation(
      tabItems,
      controller: _navigationController,
      barHeight: 60,
      barBackgroundColor: Colors.white,
      animationDuration: Duration(milliseconds: 300),
      selectedCallback: (int selectedPos) {
        setState(() {
          seciliPozisyon = selectedPos;
        });
      },
    );
  }
}
类主页扩展StatefulWidget{
@凌驾
_HomeState createState()=>\u HomeState();
}
类(HomeState扩展状态){
final _scrollController=scrollController();
列表选项卡项=List.of([
新选项卡项(Icons.home,“Anasayfa”,颜色.蓝色),
新选项卡项(Icons.message,“Sohbet Odası”,颜色为橙色),
新选项卡项(Icons.person,“Profil”,颜色为红色),
]);
int seciliPozisyon=0;
CircularBottomNavigationController(导航控制器);
@凌驾
void initState(){
super.initState();
_导航控制器=
新型循环棉航空控制器(seciliPozisyon);
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
背景颜色:Colors.black,
标题:对,
标题:文本(“加密应用程序”),
),
主体:堆栈(
儿童:[
填充物(
子项:bodyContainer(),
填充:仅限边缘设置(底部:60),
),
对齐(对齐:alignment.bottomCenter,子项:bottomNav())
],
),
);
}
Widget bodyContainer(){
字符串activeUserId=
Provider.of(context,listen:false).activeUserId;
Color selectedColor=tabItems[seciliPozisyon]。颜色;
开关(seciliPozisyon){
案例0:
返回主屏幕();
打破
案例1:
返回FriendlyChatApp();
打破
案例2:
返回配置文件(
profileId:activeUserId,
);
打破
}
}
窗口小部件底部导航(){
返回循环导航(
tabItems,
控制器:_导航控制器,
酒吧高度:60,
barBackgroundColor:Colors.white,
animationDuration:持续时间(毫秒:300),
selectedCallback:(int-selectedPos){
设置状态(){
seciliPozisyon=selectedPos;
});
},
);
}
}
聊天应用程序代码:

void main() {
  runApp(
    FriendlyChatApp(),
  );
}

final ThemeData kIOSTheme = ThemeData(
  primarySwatch: Colors.blue,
  primaryColor: Colors.grey[100],
  primaryColorBrightness: Brightness.light,
);

final ThemeData kDefaultTheme = ThemeData(
  primarySwatch: Colors.orange,
  accentColor: Colors.orangeAccent,
);

String _name = '';

class FriendlyChatApp extends StatelessWidget {
  const FriendlyChatApp({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: ChatScreen(),
    );
  }
}

class ChatMessage extends StatelessWidget {
  ChatMessage({this.text, this.animationController});
  final String text;
  final AnimationController animationController;

  @override
  Widget build(BuildContext context) {
    return SizeTransition(
      sizeFactor:
          CurvedAnimation(parent: animationController, curve: Curves.easeOut),
      axisAlignment: 0.0,
      child: Container(
        margin: EdgeInsets.symmetric(vertical: 10.0),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              margin: const EdgeInsets.only(right: 16.0),
              child: CircleAvatar(child: Text(_name[0])),
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(_name, style: Theme.of(context).textTheme.headline4),
                  Container(
                    margin: EdgeInsets.only(top: 5.0),
                    child: Text(text),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

class ChatScreen extends StatefulWidget {
  @override
  _ChatScreenState createState() => _ChatScreenState();
}

class _ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
  final List<ChatMessage> _messages = [];
  final _textController = TextEditingController();
  final FocusNode _focusNode = FocusNode();
  bool _isComposing = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        decoration: Theme.of(context).platform == TargetPlatform.iOS //new
            ? BoxDecoration(
                border: Border(
                  top: BorderSide(color: Colors.grey[200]),
                ),
              )
            : null,
        child: Column(
          children: [
            Flexible(
              child: ListView.builder(
                padding: EdgeInsets.all(8.0),
                reverse: true,
                itemBuilder: (_, int index) => _messages[index],
                itemCount: _messages.length,
              ),
            ),
            Divider(height: 1.0),
            Container(
              decoration: BoxDecoration(color: Theme.of(context).cardColor),
              child: _buildTextComposer(),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildTextComposer() {
    return IconTheme(
      data: IconThemeData(color: Theme.of(context).accentColor),
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: 8.0),
        child: Row(
          children: [
            Flexible(
              child: TextField(
                controller: _textController,
                onChanged: (String text) {
                  setState(() {
                    _isComposing = text.isNotEmpty;
                  });
                },
                onSubmitted: _isComposing ? _handleSubmitted : null,
                decoration: InputDecoration.collapsed(
                    hintText: 'Mesajınızı Buraya Yazınız:'),
                focusNode: _focusNode,
              ),
            ),
            Container(
                margin: EdgeInsets.symmetric(horizontal: 4.0),
                child: Theme.of(context).platform == TargetPlatform.iOS
                    ? CupertinoButton(
                        onPressed: _isComposing
                            ? () => _handleSubmitted(_textController.text)
                            : null,
                        child: Text('Gönder'),
                      )
                    : IconButton(
                        icon: const Icon(Icons.send),
                        onPressed: _isComposing
                            ? () => _handleSubmitted(_textController.text)
                            : null,
                      ))
          ],
        ),
      ),
    );
  }

  void _handleSubmitted(String text) {
    _textController.clear();
    setState(() {
      _isComposing = false;
    });
    var message = ChatMessage(
      text: text,
      animationController: AnimationController(
        duration: const Duration(milliseconds: 700),
        vsync: this,
      ),
    );
    setState(() {
      _messages.insert(0, message);
    });
    _focusNode.requestFocus();
    message.animationController.forward();
  }

  @override
  void dispose() {
    for (var message in _messages) {
      message.animationController.dispose();
    }
    super.dispose();
  }
}
void main(){
runApp(
FriendlyChatApp(),
);
}
最终主题数据kIOSTheme=主题数据(
主样本:颜色。蓝色,
原色:颜色。灰色[100],
primaryColorBrightness:Brightness.light,
);
最终主题数据kDefaultTheme=主题数据(
原始样本:颜色。橙色,
accentColor:Colors.orangeAccent,
);
字符串_name='';
类友好型ChatApp扩展了无状态小部件{
const FriendlyChatApp({
关键点,
}):super(key:key);
@凌驾
小部件构建(构建上下文){
返回材料PP(
debugShowCheckedModeBanner:false,
主页:ChatScreen(),
);
}
}
类ChatMessage扩展了无状态小部件{
ChatMessage({this.text,this.animationController});
最终字符串文本;
最终AnimationController AnimationController;
@凌驾
小部件构建(构建上下文){
返回大小转换(
尺寸因子:
曲线动画(父对象:animationController,曲线:Curves.easeOut),
axisAlignment:0.0,
子:容器(
边缘:边缘组。对称(垂直:10.0),
孩子:排(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
容器(
边距:仅限常量边集(右:16.0),
child:CircleAvatar(child:Text(_name[0])),
),
扩大(
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
文本(_name,style:Theme.of(context.textTheme.headline4),
容器(
边距:仅限边集(顶部:5.0),
子:文本(Text),
),
],
),
),
],
),
),
);
}
}
类ChatScreen扩展StatefulWidget{
@凌驾
_ChatScreenState createState()=>\u ChatScreenState();
}
类\u ChatScreenState使用TickerProviderStateMixin扩展状态{
最终列表_消息=[];
final _textController=TextEditingController();
最终焦点节点_FocusNode=FocusNode();
bool _isComposing=false;
@凌驾
小部件构建(构建上下文){
返回脚手架(
主体:容器(
装饰:Theme.of(context.platform==TargetPlatform.iOS//new
?盒子装饰(
边界:边界(
顶部:边框侧(颜色:Colors.grey[200]),
),
)
:null,
子:列(
儿童:[
灵活的(
子项:ListView.builder(
填充:边缘设置。全部(8.0),
相反:是的,
itemBuilder:(\u,int index)=>\u消息[索引],
itemCount:_messages.length,
),
),
分隔器(高度:1.0),
容器(
装饰:盒子装饰(颜色:主题.of(上下文).cardColor),
子项:_buildTextComposer(),
),
],
),
),
);
}
小部件_buildTextComposer(){
返回象素(
数据:IconThemeData(颜色:Theme.of(context).accentColor),
子:容器(
边缘:边缘组。对称(水平:8.0),
孩子:排(
儿童:[
灵活的(
孩子:TextField(
控制器:_textController,
onChanged:(字符串文本){
设置状态(){
_isComposing=text.isNotEmpty;
});
},
onSubmitted:_isComposing?_handleSubmitted:null,
装修:我
resizeToAvoidBottomInset: false,
Scaffold(
      //here 
        resizeToAvoidBottomInset: false,
      appBar: AppBar(
      
        backgroundColor: Colors.black,
        centerTitle: true,
        title: Text("Crypto App"),
      ),
      body: Stack(
        children: <Widget>[
          Padding(
            child: bodyContainer(),
            padding: EdgeInsets.only(bottom: 60),
          ),
          Align(alignment: Alignment.bottomCenter, child: bottomNav())
        ],
      ),
    );
  }