E/flutter (32355): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: Class 'String' has no instance setter 'text='. E/flutter (32355): Receiver: "1234567890" E/flutter (32355): Tried calling: text=Instance of 'TextEditingController'

问题描述 投票:0回答:1
个人资料屏幕

class ProfileScreenState extends State<ProfileScreen> { TextEditingController mobile = TextEditingController(); void initState() { GetDetails(); getMobile(); } @override Widget build(BuildContext context) { // TODO: implement build pr = new ProgressDialog(context, showLogs: true); pr.style(message: 'Please wait...'); return Scaffold( appBar: AppBar( title: Text("Profile", style: TextStyle(color: Colors.black)), backgroundColor: Colors.orange, ), body: SingleChildScrollView( child: Stack( children: [ Column( children: [ Container( child: Image.asset('assets/images/gym.png', height: 150, width: double.infinity, fit: BoxFit.fitWidth), ), SizedBox( height: 50, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: TextField( decoration: InputDecoration( hintText: 'User', prefixIcon: Icon(Icons.perm_identity), ), ), ), ), Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: TextField( controller: mobile, decoration: InputDecoration( prefixIcon: Icon(Icons.mobile_screen_share), ), ), ), ), ], ), ); }

从Sharedpreference获取数据

Future getMobile()异步{

Future notificatinstatus = SharedPrefrence().getUserMobile(); notificatinstatus.then((data) async { var mobile_no=data; mobile_no.text=mobile; return mobile; }); }

我有一个共享的数据,其中包含客户的移动电话号码,在我的个人资料中,当我打开个人资料页面时,需要从文本首选项数据中获取数据,当我加载数据时,需要在文本字段中填写... 
flutter flutter-layout
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.