Dart 颤振/如何在Statefulwidget之间传递和获取数据
我是一名初级(或不到一个月的学习者)dart/FLUT开发人员。 我尝试创建一个示例proflie应用程序 -在主屏幕上显示用户的配置文件图像。 -用户可以使用应用内摄像头拍照或从相册中选择并显示为个人资料图片 我已经创建了2个主视图控制器Dart 颤振/如何在Statefulwidget之间传递和获取数据,dart,flutter,Dart,Flutter,我是一名初级(或不到一个月的学习者)dart/FLUT开发人员。 我尝试创建一个示例proflie应用程序 -在主屏幕上显示用户的配置文件图像。 -用户可以使用应用内摄像头拍照或从相册中选择并显示为个人资料图片 我已经创建了2个主视图控制器 主飞镖 void main() { runApp(new MaterialApp( home: new MyApp(), routes: <String, WidgetBuilder>{ '/screen1': (BuildContex
void main() {
runApp(new MaterialApp(
home: new MyApp(),
routes: <String, WidgetBuilder>{
'/screen1': (BuildContext context) => new MyApp(),
'/screen3': (BuildContext context) => new UploadAvatarButton()
},
));
}
class MyApp extends StatefulWidget {
final String _images = "";
MyApp(String _images, {Key key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return new MyHomePage();
}
}
class MyHomePage extends State<MyApp> {
@override
Widget build(BuildContext context) {
Widget myPhoto = new Container(
//Attribute
child: new FlatButton(
child: new Container(
decoration: new BoxDecoration(
shape: BoxShape.circle,
image: new DecorationImage(
fit: BoxFit.cover, image: new AssetImage('images/sample.jpg')),
),
),
onPressed: _showPersBottomSheetCallBack,
),
);
return new MaterialApp(
home: new Scaffold(
//Header
body: new Center(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
new Container(child: myPhoto),
然而,我得到了错误
[dart] The constructor returns type 'dynamic' that isn't of expected type 'Widget'.
你能给我提个建议吗
致意
谢谢将构造函数修改为 MyApp(此.\u图像) 访问MyHomePage类中的图像 widget.\u图像
谢谢,现在可以了,很抱歉回复晚了。
List<int> imageBytes = image.readAsBytesSync();
String base64Image = BASE64.encode(imageBytes);
Navigator.push(context, new MaterialPageRoute(builder: (_) =>
new MyApp(_image.)));
final String _images = "";
MyApp(String _images, {Key key}) : super(key: key);
[dart] The constructor returns type 'dynamic' that isn't of expected type 'Widget'.