Function 如何初始化类的back4app列中的数据以在颤振中使用

Function 如何初始化类的back4app列中的数据以在颤振中使用,function,parse-platform,future,void,back4app,Function,Parse Platform,Future,Void,Back4app,所以我有一个从后台应用程序解析数据。让我们放轻松,从类用户,我做了一列的名称。那是瑞奇。 现在我想在访问变量为_name的页面时使用此列。所以它会出现在我的颤振屏幕上 Hi,(类用户中当前用户的列名) 代码 看来 嗨,瑞奇 任何人都可以帮我编写代码吗 我知道大多数调用这些用户列的函数都使用ParseObject和/或ParseUser,它总是具有Future/void类型 调用parse列的代码 class UserAccess { Future<String> namaLe

所以我有一个从后台应用程序解析数据。让我们放轻松,从类用户,我做了一列的名称。那是瑞奇。 现在我想在访问变量为_name的页面时使用此列。所以它会出现在我的颤振屏幕上

Hi,(类用户中当前用户的列名)

代码

看来

嗨,瑞奇

任何人都可以帮我编写代码吗

我知道大多数调用这些用户列的函数都使用ParseObject和/或ParseUser,它总是具有Future/void类型

调用parse列的代码

class UserAccess {


  Future<String> namaLengkap() async {
    ParseUser currentUser = await ParseUser.currentUser() as ParseUser;
    String nl = await currentUser.get('NamaLengkap');
    return nl;
  }
}
class用户访问{
Future namaLengkap()异步{
ParseUser currentUser=等待ParseUser.currentUser()作为ParseUser;
字符串nl=等待currentUser.get('NamaLengkap');
返回nl;
}
}
这是我访问函数的地方(注意,我不发布导入)

class Home2扩展了StatefulWidget{
@凌驾
_Home2State createState();
}
类_Home2State扩展状态{
字符串_nama;
布尔乌萨哈;
showFailedBusinessDialog(构建上下文){
小部件okButton=ElevatedButton(
孩子:文本(“OK”),
onPressed:(){Navigator.of(context.pop();},
);
AlertDialog alert=AlertDialog(
内容:文本(“Anda harus mendaftarkan\nusaha Anda dahulu!”),
行动:[
okButton,
],
);
显示对话框(
上下文:上下文,
生成器:(BuildContext上下文){
返回警报;
},
);
}
@凌驾
小部件构建(构建上下文){
Timer.run(()异步{
final _nama=wait UserAccess().namaLengkap();
返回_nama;
});
Timer.run(()异步{
_usaha=await UserAccess().AdaUsaha();
返回_usaha;
});
返回安全区(
孩子:脚手架(
appBar:appBar(
标题:文本('Daur.id'),
titleTextStyle:TextStyle(
字体大小:48.0,
fontWeight:fontWeight.bold
),
标题:对,
阴影颜色:颜色。黑色,
背景颜色:CupertinoColors.activeBlue,
标高:5.0,
形状:圆形矩形边框(
borderRadius:borderRadius.vertical(
底部:半径。圆形(20),
),
),
行动:[
图标按钮(图标:图标(CupertinoIcons.bell_fill,颜色:Colors.black,),ON按下:(){
推式新闻屏幕(
上下文
屏幕:Notifikasi(),
withNavBar:false,
pageTransitionAnimation:pageTransitionAnimation.cupertino,
);
})
],
),
主体:堆栈(
儿童:[
容器(
装饰:盒子装饰(
图像:装饰图像(
图像:AssetImage('assets/images/background1.jpeg'),
适合:BoxFit.cover
)
),
),
SingleChildScrollView(
子:容器(
填充:来自LTRB(15.0,10.0,15.0,40.0)的边缘设置,
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
划船(
儿童:[
纵队(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
对齐(对齐:对齐.中间偏左,子项:文本('Hai,$\nama',textAlign:textAlign.start,样式:TextStyle(fontSize:24.0,fontWeight:fontWeight.bold)),
尺寸箱(高度:5.0,),
Text('Mari kita bersihkan sampah dari lingkungan',风格:TextStyle(fontSize:14.0),)
],
),
尺寸标注框(宽度:30.0,),
ImagePickerWidget(
直径:60,
初始图像:“https://apprecs.org/gp/images/app-icons/300/81/com.unzypsoft.rekeningbookapps2.jpg" ,
形状:ImagePickerWidgetShape.circle,
可编辑:错误,
),
],
),
尺寸箱(高度:20.0,),
容器(
装饰:盒子装饰(
边界半径:边界半径。圆形(20.0),
颜色:Colors.blueAccent,
boxShadow:[boxShadow(
颜色:颜色,黑色,
半径:10.0,
偏移量:偏移量(0,2)
)],),
身高:120.0,
宽度:400.0,
孩子:脚手架(
appBar:appBar(
背景颜色:Colors.white,
阴影颜色:颜色。黑色,
高度:30.0,
标题:文本('D点',样式:文本样式(颜色:Colors.black),),
),
正文:专栏(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
尺寸箱(高度:5.0,),
划船(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
图标按钮(图标大小:50.0,图标:图标(图标。添加注释),按下:(){
推式新闻屏幕(
上下文
屏幕:orderIndividual(),
withNavBar:false,
pageTransitionAnimation:pageTransitionAnimation.cupertino,
class UserAccess {


  Future<String> namaLengkap() async {
    ParseUser currentUser = await ParseUser.currentUser() as ParseUser;
    String nl = await currentUser.get('NamaLengkap');
    return nl;
  }
}
class Home2 extends StatefulWidget {
  @override
  _Home2State createState() => _Home2State();
}

class _Home2State extends State<Home2> {
  String _nama;
  bool _usaha;


  showFailedBusinessDialog(BuildContext context) {
    Widget okButton = ElevatedButton(
      child: Text("OK"),
      onPressed: () {Navigator.of(context).pop();},
    );
    AlertDialog alert = AlertDialog(
      content: Text("Anda harus mendaftarkan\nusaha anda dahulu!"),
      actions: [
        okButton,
      ],
    );
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return alert;
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    Timer.run(() async {
      final _nama = await UserAccess().namaLengkap();
      return _nama;
    });
    Timer.run(() async {
      _usaha = await UserAccess().AdaUsaha();
      return _usaha;
    });
    return SafeArea(
      child: Scaffold(
        appBar: AppBar(
          title: Text('Daur.id'),
          titleTextStyle: TextStyle(
            fontSize: 48.0,
            fontWeight: FontWeight.bold
          ),
          centerTitle: true,
          shadowColor: Colors.black,
          backgroundColor: CupertinoColors.activeBlue,
          elevation: 5.0,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.vertical(
              bottom: Radius.circular(20),
            ),
          ),
          actions: [
            IconButton(icon: Icon(CupertinoIcons.bell_fill, color: Colors.black,), onPressed: (){
              pushNewScreen(
                context,
                screen: Notifikasi(),
                withNavBar: false,
                pageTransitionAnimation: PageTransitionAnimation.cupertino,
              );
            })
          ],
        ),
        body: Stack(
          children: [
            Container(
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage('assets/images/background1.jpeg'),
                      fit: BoxFit.cover
                  )
              ),
            ),
            SingleChildScrollView(
              child: Container(
                padding: EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 40.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      children: [
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Align(alignment: Alignment.centerLeft,child: Text('Hai, $_nama',textAlign: TextAlign.start,style: TextStyle(fontSize: 24.0,fontWeight: FontWeight.bold))),
                            SizedBox(height: 5.0,),
                            Text('Mari kita bersihkan sampah dari lingkungan',style: TextStyle(fontSize: 14.0),)
                          ],
                        ),
                        SizedBox(width: 30.0,),
                        ImagePickerWidget(
                          diameter: 60,
                          initialImage: "https://apprecs.org/gp/images/app-icons/300/81/com.unzypsoft.rekeningbookapps2.jpg" ,
                          shape: ImagePickerWidgetShape.circle,
                          isEditable: false,
                        ),
                      ],
                    ),
                    SizedBox(height: 20.0,),
                    Container(
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20.0),
                        color: Colors.blueAccent,
                        boxShadow: [BoxShadow(
                            color: Colors.black,
                            blurRadius: 10.0,
                            offset: Offset(0, 2)
                        )],),
                      height: 120.0,
                      width: 400.0,
                      child: Scaffold(
                        appBar: AppBar(
                          backgroundColor: Colors.white,
                          shadowColor: Colors.black,
                          toolbarHeight: 30.0,
                          title: Text('D Points',style: TextStyle(color: Colors.black),),
                        ),
                        body: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            SizedBox(height:5.0,),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                IconButton(iconSize: 50.0,icon: Icon(Icons.add_comment_outlined), onPressed: (){
                                  pushNewScreen(
                                    context,
                                    screen: OrderIndividu(),
                                    withNavBar: false,
                                    pageTransitionAnimation: PageTransitionAnimation.cupertino,
                                  );
                                }),
                                SizedBox(width: 30.0,),
                                IconButton(iconSize: 50.0,icon: Icon(Icons.assignment_return_outlined), onPressed: (){}),
                                SizedBox(width: 30.0,),
                                IconButton(iconSize: 50.0,icon: Icon(Icons.add_circle_outline), onPressed: (){
                                  if(_usaha == true){
                                    pushNewScreen(
                                      context,
                                      screen: OrderUsaha(),
                                      withNavBar: false,
                                      pageTransitionAnimation: PageTransitionAnimation.cupertino,
                                    );
                                  } else{
                                    showFailedBusinessDialog(context);
                                  };
                                }),
                                SizedBox(width: 30.0,),
                                IconButton(iconSize: 50.0,icon: Icon(Icons.redeem_sharp), onPressed: (){}),
                              ],
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.start,
                              children: [
                                SizedBox(width: 24.0,),
                                Text('Top Up'),
                                SizedBox(width: 57.0,),
                                Text('Share'),
                                SizedBox(width: 57.0,),
                                Text('Usaha'),
                                SizedBox(width: 50.0,),
                                Text('Redeem')
                              ],
                            )
                          ],
                        ),
                      ),
                    ),
                    SizedBox(height: 20.0,),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        SizedBox(width: 20.0,),
                        IconButton(icon: Icon(CupertinoIcons.cube_box_fill, size: 50.0,color: Colors.green,), onPressed: (){}),
                        SizedBox(width: 40.0,),
                        IconButton(icon: Icon(CupertinoIcons.bus, size: 50.0,color: Colors.blue,), onPressed: (){}),
                        SizedBox(width: 40.0,),
                        IconButton(icon: Icon(CupertinoIcons.bag_fill, size: 50.0,color: Colors.orange,), onPressed: (){
                          pushNewScreen(
                            context,
                            screen: DaftarUsahaFront(),
                            withNavBar: false,
                            pageTransitionAnimation: PageTransitionAnimation.cupertino,
                          );
                        }),
                        SizedBox(width: 40.0,),
                        IconButton(icon: Icon(CupertinoIcons.archivebox_fill, size: 50.0,color: Colors.red,), onPressed: (){}),
                        SizedBox(width: 40.0,),
                      ],
                    ),
                    SizedBox(height: 10.0,),
                    Row(
                      children: [
                        SizedBox(width: 35.0,),
                        Text('PickUp'),
                        SizedBox(width: 35.0,),
                        Text('Drop Off'),
                        SizedBox(width: 40.0,),
                        Text('Usaha'),
                        SizedBox(width: 55.0,),
                        Text('Event'),
                      ],
                    ),
                    // 3 BOX KOSONG SEMENTARA AJA
                    SizedBox(height: 30.0),
                    // CarouselSlider(items: items, options: options),
                    SizedBox(height: 30.0),
                    Container(
                      height: 100.0,
                      width: 100.0,
                      color: Colors.blue,
                    ),
                    SizedBox(height: 30.0),
                    Container(
                      height: 100.0,
                      width: 100.0,
                      color: Colors.green,
                    ),
                    SizedBox(height: 30.0),
                    // ISI KOTAK INI CONG
                    Container(
                      height: 350.0,
                      width: 400.0,
                      padding: EdgeInsets.all(10.0),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20.0),
                        color: Colors.white,
                        boxShadow: [BoxShadow(
                            color: Colors.black,
                            blurRadius: 10.0,
                            offset: Offset(0, 2)
                        )],),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('Statistik Daur Ulang', style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),),
                          Text('Kamu hebat, berikut hasil usaha daur ulangmu \nbersama Mall Daur!',style: TextStyle(fontSize: 16.0), ),
                          SizedBox(height: 10.0,),
                          Row(
                            children: [
                              SizedBox(width: 7.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.red,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Kertas'),
                              ),
                              SizedBox(width: 10.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.blue,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Kaca'),
                              ),
                            ],
                          ),
                          SizedBox(height: 10.0,),
                          Row(
                            children: [
                              SizedBox(width: 7.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.green,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Elektronik'),
                              ),
                              SizedBox(width: 10.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.orange,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Besi dan Logam'),
                              ),
                            ],
                          ),
                          SizedBox(height: 10.0,),
                          Row(
                            children: [
                              SizedBox(width: 7.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.purple,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Plastik'),
                              ),
                              SizedBox(width: 10.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.brown,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Alumunium'),
                              ),
                            ],
                          ),
                          SizedBox(height: 10.0,),
                          Row(
                            children: [
                              SizedBox(width: 7.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.pink,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Fabric/Baju'),
                              ),
                              SizedBox(width: 10.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.amber,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Kayu'),
                              ),
                            ],
                          ),
                          SizedBox(height: 10.0,),
                          Row(
                            children: [
                              SizedBox(width: 7.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.cyan,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Bio'),
                              ),
                              SizedBox(width: 10.0,),
                              Container(
                                height: 40.0,
                                width: 170.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(5.0),
                                  color: Colors.white,
                                  boxShadow: [BoxShadow(
                                      color: Colors.black,
                                      blurRadius: 10.0,
                                      offset: Offset(0, 2)
                                  )],),
                                child: Text('Mix'),
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}