-
-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathmain_custom_card.dart
More file actions
83 lines (73 loc) · 2.17 KB
/
main_custom_card.dart
File metadata and controls
83 lines (73 loc) · 2.17 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
// Copyright (c) 2023 Larry Aasen. All rights reserved.
import 'package:flutter/material.dart';
import 'package:upgrader/upgrader.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Only call clearSavedSettings() during testing to reset internal values.
await Upgrader.clearSavedSettings(); // REMOVE this for release builds
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Upgrader Example',
home: Scaffold(
appBar: AppBar(title: const Text('Upgrader Custom Card Example')),
body: Container(
margin: const EdgeInsets.only(left: 12.0, right: 12.0),
child: SingleChildScrollView(
child: Column(
children: [
_simpleCard,
_simpleCard,
MyUpgradeCard(),
_simpleCard,
_simpleCard,
],
),
),
),
),
);
}
Widget get _simpleCard => const Card(
child: SizedBox(
width: 200,
height: 50,
child: Center(child: Text('Card')),
),
);
}
class MyUpgradeCard extends UpgradeCard {
MyUpgradeCard({super.key, super.upgrader});
/// Override the [createState] method to provide a custom class
/// with overridden methods.
@override
UpgradeCardState createState() => MyUpgradeCardState();
}
class MyUpgradeCardState extends UpgradeCardState {
@override
Widget buildUpgradeCard(BuildContext context, Key? key) {
final appMessages = widget.upgrader.determineMessages(context);
final title = appMessages.message(UpgraderMessage.title);
return Card(
color: Colors.greenAccent,
child: AlertStyleWidget(
actions: [
TextButton(
child: Text(
appMessages.message(UpgraderMessage.buttonTitleUpdate) ?? ''),
onPressed: () {
widget.upgrader.saveLastAlerted();
onUserUpdated();
},
),
],
content: const Text(''),
title: Text(title ?? ''),
),
);
}
}