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

问题描述

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

您好,(User 类当前用户的列名)

代码

Text('Hai,$_nama',textAlign: TextAlign.start,style: TextStyle(fontSize: 24.0,fontWeight: FontWeight.bold))

所以它看起来像

嗨,瑞奇

有人可以帮忙编写代码吗?

我知道调用那些 User 列的大多数函数使用 ParSEObject 和/或 ParseUser 并且它总是具有 Future/void 类型。

调用解析列的代码

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,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,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(),);
                                }),IconButton(iconSize: 50.0,icon: Icon(Icons.assignment_return_outlined),onpressed: (){}),icon: Icon(Icons.add_circle_outline),onpressed: (){
                                  if(_usaha == true){
                                    pushNewScreen(
                                      context,screen: OrderUsaha(),);
                                  } else{
                                    showFailedBusinessDialog(context);
                                  };
                                }),icon: Icon(Icons.redeem_sharp),Row(
                              mainAxisAlignment: MainAxisAlignment.start,children: [
                                SizedBox(width: 24.0,Text('Top Up'),SizedBox(width: 57.0,Text('Share'),Text('Usaha'),SizedBox(width: 50.0,Text('Redeem')
                              ],Row(
                      mainAxisAlignment: MainAxisAlignment.center,children: [
                        SizedBox(width: 20.0,IconButton(icon: Icon(CupertinoIcons.cube_Box_fill,size: 50.0,color: Colors.green,SizedBox(width: 40.0,IconButton(icon: Icon(CupertinoIcons.bus,color: Colors.blue,IconButton(icon: Icon(CupertinoIcons.bag_fill,color: Colors.orange,onpressed: (){
                          pushNewScreen(
                            context,screen: DaftarUsahaFront(),);
                        }),IconButton(icon: Icon(CupertinoIcons.archiveBox_fill,color: Colors.red,SizedBox(height: 10.0,Row(
                      children: [
                        SizedBox(width: 35.0,Text('PickUp'),SizedBox(width: 35.0,Text('Drop Off'),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,// ISI KOTAK INI CONG
                    Container(
                      height: 350.0,padding: EdgeInsets.all(10.0),decoration: Boxdecoration(
                        borderRadius: BorderRadius.circular(20.0),color: Colors.white,child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,children: [
                          Text('Statistik Daur Ulang',fontWeight: FontWeight.bold),Text('Kamu hebat,berikut hasil usaha daur ulangmu \nbersama Mall Daur!',style: TextStyle(fontSize: 16.0),Row(
                            children: [
                              SizedBox(width: 7.0,Container(
                                height: 40.0,width: 170.0,decoration: Boxdecoration(
                                  borderRadius: BorderRadius.circular(5.0),BoxShadow: [BoxShadow(
                                      color: Colors.black,2)
                                  )],child: Text('Kertas'),SizedBox(width: 10.0,child: Text('Kaca'),child: Text('Elektronik'),child: Text('Besi dan Logam'),color: Colors.purple,child: Text('Plastik'),color: Colors.brown,child: Text('Alumunium'),color: Colors.pink,child: Text('Fabric/Baju'),color: Colors.Amber,child: Text('Kayu'),color: Colors.cyan,child: Text('Bio'),child: Text('Mix'),)
          ],);
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)