-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat.dart
70 lines (65 loc) · 1.71 KB
/
cat.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:cached_network_image/cached_network_image.dart';
import 'session.dart';
import 'util.dart';
import 'dart:convert';
import 'dart:io';
class CatPage extends StatelessWidget {
String name = '';
String url = '';
final Map<String, dynamic>? cat;
final Map<String, dynamic>? user;
BuildContext otherContext;
CatPage(this.url, this.cat, this.user, this.otherContext) {
name = cat?["name"].toString() ?? '';
}
Widget buildBody(BuildContext context) {
return Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: buildTextField(),
),
AspectRatio(
aspectRatio: 16 / 9,
child: CachedNetworkImage(
imageUrl: url,
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
fit: BoxFit.cover,
),
),
],
);
}
Widget buildTextField() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
],
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
leading: IconButton(
icon: Icon(Icons.arrow_back),
color: Colors.black,
onPressed: () {
Navigator.pop(otherContext);
},
),
title: Image.asset( 'assets/paws.jpg', width: 280, height: 100),
),
body: buildBody(context),
);
}
}