Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.42 KB | None | 0 0
  1. class HomeTab extends StatelessWidget {
  2.   Resp resp;
  3.  
  4.   @override
  5.   Widget build(BuildContext context) {
  6.     Future<String> getJSONData() async {
  7.       var response = await http.get(
  8.           Uri.encodeFull(
  9.               "http://treinamento.educ.ifrn.edu.br/api/educ/diario/meus_diarios/"),
  10.           headers: {
  11.             "Authorization": "Token dfba99dbad894452f843d1af00ffbcd559c63e59"
  12.           });
  13.  
  14.       print('Response status: ${response.statusCode}');
  15.       //print('Response body: ${response.body}');
  16.  
  17.       Map userMap = jsonDecode(response.body);
  18.       resp = Resp.fromJson(userMap["result"][0]);
  19.       print(resp.componente.text);
  20.  
  21.       //  List<User> users = userMap['result'].map<User>((json)=>
  22.       //     User.fromJson(json),
  23.  
  24.       //  ).toList();
  25.  
  26.       // print(users.toString());
  27.     }
  28.  
  29.     getJSONData();
  30.     // Trabalhando o Degrade do app
  31.     Widget _buildBodyBack() => Container(
  32.           decoration: BoxDecoration(
  33.               gradient: LinearGradient(colors: [
  34.             Color.fromARGB(255, 51, 55, 232),
  35.             Color.fromARGB(255, 56, 113, 255),
  36.           ], begin: Alignment.topLeft, end: Alignment.bottomRight)),
  37.         );
  38.  
  39.     // stack para quando quer escrever algo em cima de um fundo
  40.     return Stack(
  41.       children: <Widget>[
  42.         _buildBodyBack(),
  43.         CustomScrollView(
  44.           slivers: <Widget>[
  45.             SliverAppBar(
  46.               //Onde deixa o item fixo no Scroll
  47.               floating: true,
  48.               snap:
  49.                   true, // quando abaixar a tela o titulo vai sumir. Quando subir, ele reaparece.
  50.               backgroundColor: Colors.transparent,
  51.               elevation: 0.0,
  52.               flexibleSpace: FlexibleSpaceBar(
  53.                 title: const Text("Educ Panel"),
  54.                 centerTitle: true,
  55.               ),
  56.             ),
  57.  
  58.              SingleChildScrollView(
  59.               scrollDirection: Axis.horizontal,
  60.               child: DataTable(
  61.                 columns: [
  62.                   DataColumn(label: Text('Nome')),
  63.                   DataColumn(
  64.                       label: Text(
  65.                     'Matricula',
  66.                     overflow: TextOverflow.ellipsis,
  67.                   )),
  68.                   DataColumn(label: Text('Notas')),
  69.                   DataColumn(label: Text('Frequencia')),
  70.                 ],
  71.               ),
  72.             )
  73.           ],
  74.         )
  75.       ],
  76.     );
  77.   }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement