-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathskeleton_theme.dart
More file actions
90 lines (85 loc) · 2.44 KB
/
Copy pathskeleton_theme.dart
File metadata and controls
90 lines (85 loc) · 2.44 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import 'package:flutter/material.dart';
import 'package:skeletons/skeletons.dart';
class SkeletonThemeExamplePage extends StatefulWidget {
@override
_SkeletonThemeExamplePageState createState() =>
_SkeletonThemeExamplePageState();
}
class _SkeletonThemeExamplePageState extends State<SkeletonThemeExamplePage> {
bool _isLoading = true;
void _toggleLoading() {
setState(() {
_isLoading = !_isLoading;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFC7E5EE),
appBar: AppBar(
title: Text("SkeletonTheme"),
),
body: SkeletonTheme(
themeMode: ThemeMode.light,
shimmerGradient: LinearGradient(
colors: [
Color(0xFF67C5E2),
Color(0xFF18A6D1),
Color(0xFF67C5E2),
],
stops: [
0.1,
0.5,
0.9,
],
),
child: Skeleton(
duration: Duration(milliseconds: 800),
isLoading: _isLoading,
skeleton: SkeletonListView(
item: SkeletonListTile(
contentSpacing: 24,
padding: EdgeInsets.symmetric(vertical: 16),
leadingStyle: SkeletonAvatarStyle(width: 32, height: 24),
titleStyle:
SkeletonLineStyle(borderRadius: BorderRadius.circular(4)),
hasSubtitle: false,
)),
child: _contentView(),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _toggleLoading,
child: Icon(
_isLoading ? Icons.hourglass_full : Icons.hourglass_bottom,
),
),
);
}
Widget _contentView() => ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 16.0),
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Row(
children: [
Icon(
Icons.panorama,
size: 28,
),
SizedBox(
width: 24,
),
Expanded(
child: Text(
"Lorem ipsum dolor sit amet.",
style: Theme.of(context).textTheme.headlineSmall,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
)
],
),
),
);
}