Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.38 KB | None | 0 0
  1. class _MyAppState extends State<MyApp> {
  2.   @override
  3.   Widget build(BuildContext context) {
  4.     return FutureBuilder<bool>(
  5.       future: get_login(),
  6.       builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
  7.         if (snapshot.connectionState == ConnectionState.done) {
  8.           if (snapshot.data == false) {
  9.             //tidak ada akun login
  10.             return FutureBuilder(
  11.               future: Hive.openBox('pgguna'),
  12.               builder: (context, snapshot) {
  13.                 if (snapshot.connectionState == ConnectionState.done) {
  14.                   if (snapshot.hasError) {
  15.                     return Scaffold(
  16.                       body: Container(
  17.                         child: Center(
  18.                           child: Text(snapshot.error.toString()),
  19.                         ),
  20.                       ),
  21.                     );
  22.                   }
  23.                   return MaterialApp(
  24.                     home: Scaffold(
  25.                       body: WatchBoxBuilder(
  26.                         box: pguna,
  27.                         builder: (context, pguna) => ListView.builder(
  28.                           itemCount: pguna.length,
  29.                           itemBuilder: (context, index) {
  30.                             pengguna ujip = pguna.getAt(index);
  31.                             return Text(ujip.foto_p);
  32.                           },
  33.                         ),
  34.                       ),
  35.                     ),
  36.                   );
  37.                 }
  38.                 return MaterialApp(
  39.                   home: Scaffold(
  40.                     body: Container(
  41.                       child: Center(
  42.                         child: CupertinoActivityIndicator(),
  43.                       ),
  44.                     ),
  45.                   ),
  46.                 );
  47.               },
  48.             );
  49.           }
  50.           return FutureBuilder(
  51.             future: Hive.openBox('pgguna'),
  52.             builder: (context, snapshot) {
  53.               if (snapshot.connectionState == ConnectionState.done) {
  54.                 if (snapshot.hasError) {
  55.                   return Scaffold(
  56.                     body: Container(
  57.                       child: Center(
  58.                         child: Text(snapshot.error.toString()),
  59.                       ),
  60.                     ),
  61.                   );
  62.                 }
  63.                 get_akun().then((s) {
  64.                   no_hp_p = s;
  65.                 });
  66.                 return WatchBoxBuilder(
  67.                   box: pguna,
  68.                   builder: (context, pguna) => ListView.builder(
  69.                     itemCount: pguna.length,
  70.                     itemBuilder: (context, index) {
  71.                       pengguna ujip = pguna.getAt(index);
  72.                       return Text(ujip.foto_p);
  73.                     },
  74.                   ),
  75.                 );
  76.               }
  77.               return MaterialApp(
  78.                 home: Scaffold(
  79.                   body: Container(
  80.                     child: Center(
  81.                       child: CupertinoActivityIndicator(),
  82.                     ),
  83.                   ),
  84.                 ),
  85.               );
  86.             },
  87.           );
  88.         }
  89.         return MaterialApp(
  90.           home: Scaffold(
  91.             body: Container(
  92.               child: Center(
  93.                 child: CupertinoActivityIndicator(),
  94.               ),
  95.             ),
  96.           ),
  97.         );
  98.       },
  99.     );
  100.   }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement