Flutter应用程式在editable_text中引发错误

时间:2020-06-16 05:19:40

标签: flutter

enter image description here

我是新手。该错误不会消失,我也不知道这意味着什么或如何解决。有人可以帮我吗?有时该应用可以运行,但首先在屏幕上显示错误标签。 此外,所选图片不是动态图片,即,选择图片后,它会引发错误并且不会对其进行更新。这是我的代码-

import 'package:flutter/material.dart';
import 'dart:io';
import 'package:image_picker/image_picker.dart';

void main() => runApp(MaterialApp(
  home: Home(),
));

class Home extends StatefulWidget {

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  File _imageFile;
  Future getImage (bool isCamera) async{
    File image;
    if(isCamera){
      // ignore: deprecated_member_use
      image = await ImagePicker.pickImage(source: ImageSource.camera);
    }
    else {
      image = await ImagePicker.pickImage(source: ImageSource.gallery);
    }
    setState(() {
      _imageFile = image;
    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.grey[800],
          centerTitle:true,
          title:Text(
            'Profile',
          ),
        ),
        drawer: Drawer(
          child: ListView(
            padding: EdgeInsets.zero,
            children: <Widget>[
              DrawerHeader(
                child: Text('Drawer Header'),
                decoration: BoxDecoration(
                  color: Colors.blue,
                ),
              ),
              ListTile(
                title: Text('Change Password'),
                onTap: () {
                  Navigator.pop(context);
                },
              ),
              ListTile(
                title: Text('Settings'),
                onTap: () {
                  Navigator.pop(context);
                },
              ),
            ],
          ),
        ),
        body:SingleChildScrollView(
        child:Column(children: <Widget>[
          SizedBox(height: 20.0),
          Center(
            child: CircleAvatar(
              backgroundImage: _imageFile == null ? AssetImage('images/profilepic.jpg') : Image.file(_imageFile),
              radius: 60.0,
            ),
          ),
          SizedBox(height: 20.0),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
              children:<Widget>[
            Text('UserName',
                style: TextStyle(
                  fontSize: 25.0,
                  fontFamily: ' MuseoModerno',
                )),
          ]),
          SizedBox(height: 40.0),
          RaisedButton(
            child: Text('Camera'),
            onPressed:() {
              getImage(true);
            },
          ),
          RaisedButton(
            child: Text('Gallery'),
            onPressed:() {
              getImage(false);
            },
          ),
        ]
        )
        )
    );
  }
}

0 个答案:

没有答案