-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathanimated_error.dart
More file actions
51 lines (47 loc) · 1.48 KB
/
animated_error.dart
File metadata and controls
51 lines (47 loc) · 1.48 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
// ignore_for_file: public_member_api_docs, library_private_types_in_public_api
import 'package:flutter/material.dart';
class AnimatedError extends StatefulWidget {
const AnimatedError({
Key? key,
this.show = false,
required this.text,
}) : super(key: key);
final bool show;
final String text;
@override
_AnimatedErrorState createState() => _AnimatedErrorState();
}
class _AnimatedErrorState extends State<AnimatedError>
with SingleTickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: AnimatedSize(
curve: Curves.easeInOut,
clipBehavior: Clip.antiAliasWithSaveLayer,
duration: const Duration(milliseconds: 180),
child: Visibility(
key: ValueKey(widget.show),
visible: widget.show,
child: Container(
alignment: AlignmentDirectional.centerStart,
padding: const EdgeInsets.all(10),
margin: const EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondary,
borderRadius: BorderRadius.circular(5),
),
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: Text(
widget.show ? widget.text : '',
key: ValueKey<String>(widget.text),
),
),
),
),
),
);
}
}