huxiaoqiang 4 gadi atpakaļ
vecāks
revīzija
717d779535

+ 36 - 29
lib/paegs/mine_page/my_information_page/my_information_page.dart

@@ -1,6 +1,7 @@
 import 'dart:convert';
 import 'dart:io';
 
+import 'package:bbyyy/beans/login_information_bean_entity.dart';
 import 'package:bbyyy/beans/upload_image_bean_entity.dart';
 import 'package:bbyyy/https/MyDio.dart';
 import 'package:bbyyy/https/my_request.dart';
@@ -11,9 +12,9 @@ import 'package:bbyyy/my_tools/my_tools.dart';
 import 'package:bbyyy/my_tools/my_views.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
 import 'package:flutter_svg/flutter_svg.dart';
-import 'package:bbyyy/my_tools/event_bus.dart';
-import 'package:bbyyy/beans/login_information_bean_entity.dart';
+
 class MyInformationPage extends StatefulWidget {
   @override
   _MyInformationPageState createState() => _MyInformationPageState();
@@ -159,33 +160,38 @@ class _MyInformationPageState extends State<MyInformationPage> {
                                   margin: EdgeInsets.only(right: 28),
                                 ),
                                 Expanded(
-                                    child: TextField(
-                                  controller: _name,
-                                  cursorColor: MyColors.cFF4233,
-                                  cursorWidth: 1.0,
-                                  onTap: () {},
-                                  textAlign: TextAlign.start,
-                                  decoration: InputDecoration(
-                                    border: InputBorder.none,
-                                    disabledBorder: InputBorder.none,
-                                    enabledBorder: InputBorder.none,
-                                    focusedBorder: InputBorder.none,
-                                    isDense: true,
-                                    hintText: '请输入名称',
-                                    hintStyle: TextStyle(
-                                        color: MyColors.c999999, fontSize: 16),
-                                    contentPadding: const EdgeInsets.fromLTRB(
-                                        0, 4.5, 0, 4.5),
+                                  child: TextField(
+                                    inputFormatters: [
+                                      LengthLimitingTextInputFormatter(12)
+                                    ],
+                                    controller: _name,
+                                    cursorColor: MyColors.cFF4233,
+                                    cursorWidth: 1.0,
+                                    onTap: () {},
+                                    textAlign: TextAlign.start,
+                                    decoration: InputDecoration(
+                                      border: InputBorder.none,
+                                      disabledBorder: InputBorder.none,
+                                      enabledBorder: InputBorder.none,
+                                      focusedBorder: InputBorder.none,
+                                      isDense: true,
+                                      hintText: '请输入名称',
+                                      hintStyle: TextStyle(
+                                          color: MyColors.c999999,
+                                          fontSize: 16),
+                                      contentPadding: const EdgeInsets.fromLTRB(
+                                          0, 4.5, 0, 4.5),
+                                    ),
+                                    maxLines: 1,
+                                    style: TextStyle(
+                                        color: MyColors.c333333,
+                                        fontSize: 16,
+                                        height: 1.3,
+                                        letterSpacing: 0.2),
+                                    keyboardType: TextInputType.text,
+                                    onChanged: (t) {},
                                   ),
-                                  maxLines: 1,
-                                  style: TextStyle(
-                                      color: MyColors.c333333,
-                                      fontSize: 16,
-                                      height: 1.3,
-                                      letterSpacing: 0.2),
-                                  keyboardType: TextInputType.text,
-                                  onChanged: (t) {},
-                                ))
+                                ),
                               ],
                             ),
                           ),
@@ -265,7 +271,8 @@ class _MyInformationPageState extends State<MyInformationPage> {
     }, (response, hasError) {
       if (!hasError) {
         showToast('修改成功');
-        LoginInformationBeanEntity loginInformation = MyCookie().loginInformation;
+        LoginInformationBeanEntity loginInformation =
+            MyCookie().loginInformation;
         loginInformation.data.extra.picture = path;
         loginInformation.data.extra.name = _name.text.toString();
         MyCookie().saveLoginInformationBeanEntity(loginInformation);

+ 3 - 0
lib/paegs/registered_page/registered_page.dart

@@ -225,6 +225,9 @@ class _RegisteredPageState extends State<RegisteredPage> {
                             ),
                             Expanded(
                               child: TextField(
+                                inputFormatters: [
+                                  LengthLimitingTextInputFormatter(12)
+                                ],
                                 controller: _nickname,
                                 cursorColor: MyColors.cFF4233,
                                 cursorWidth: 1.0,