如何阻止此消息出现在终端中?

问题描述 投票:0回答:1

选择 TextField() 且光标不断重新渲染时的终端输出

D/EGL_emulation( 4035): app_time_stats: avg=500.42ms min=487.06ms max=513.77ms count=2

问题是,当我在模拟器中打开 TextField 时,它会不断在终端中重复该烦人的消息。一旦我退出文本字段,它就会停止打印该错误。有人可以帮我吗?

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:learn_to_connect_api/utils/Ccolors.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

class LoginPage extends StatefulWidget {



  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {

  Future<bool> checkIfUserIsCorrect(String password, String email) async{

    Map<String, dynamic> parameters = {
      "key": "69420911",
      "email": email,
    };

    var url = Uri.http("192.168.1.14:3000", "users", parameters);
    var response = await http.get(url);

    dynamic fetchedData = jsonDecode(response.body);

    if(fetchedData['code'] == 404){
      print("-----------------404--------------------");
      return false;
    }

    print("Status code:  ${response.statusCode}");
    print(fetchedData['data']);

    return true;
  }

  final TextEditingController emailController = TextEditingController();
  final TextEditingController passwordController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Ccolors.bgColor,
      body: SafeArea(
        child: Center(
          child: Container(
            padding: EdgeInsets.symmetric(horizontal: 50),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                  child: Text(
                      "Login",
                    style: TextStyle(
                      fontSize: 28,
                      fontWeight: FontWeight.bold
                    ),
                  ),
                ),
                SizedBox(height: 50),
                Container(
                  decoration: BoxDecoration(
                    color: Colors.black38,
                    borderRadius: BorderRadius.circular(8),
                  ),
                  child: TextField(
                    controller: emailController,
                    keyboardType: TextInputType.emailAddress,
                    decoration: InputDecoration(
                      prefixIcon: Icon(Icons.email),
                      hintText: "Email",
                      border: InputBorder.none
                    ),
                  )
                ),
                SizedBox(height: 20),
                Container(
                  decoration: BoxDecoration(
                    color: Colors.black38,
                    borderRadius: BorderRadius.circular(8),
                  ),
                  child: TextField(
                    controller: passwordController,
                    obscureText: true,
                    keyboardType: TextInputType.text,
                    decoration: InputDecoration(
                      prefixIcon: Icon(Icons.lock),
                      hintText: "Password",
                      border: InputBorder.none
                    ),
                  ),
                ),
                SizedBox(height: 40),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    ElevatedButton(onPressed: () {context.go('/login_and_register');}, child: Text("Back")),
                    SizedBox(width: 15),
                    ElevatedButton(onPressed: () async {
                      if(emailController.text.isEmpty || passwordController.text.isEmpty) {
                        return;
                      }

                      if(!(await checkIfUserIsCorrect(passwordController.text, emailController.text))){
                        return;
                      }

                      context.go('/');
                    },
                    child: Text("Submit"))
                  ],
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}

我想减少终端中的混乱程度并优化重新渲染问题。

flutter dart debugging terminal rendering
1个回答
0
投票

如果您使用 Android Studio,请在终端中选择消息的开头,例如:

D/EGL_emulation(

然后右键单击并选择“像这样折叠线”。之后类似的消息将被折叠

© www.soinside.com 2019 - 2024. All rights reserved.