-
-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathmain_alert_theme.dart
More file actions
68 lines (59 loc) · 1.87 KB
/
main_alert_theme.dart
File metadata and controls
68 lines (59 loc) · 1.87 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
// Copyright (c) 2024 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: MyUpgradeAlert(
child: Scaffold(
appBar: AppBar(title: const Text('Upgrader Alert Theme Example')),
body: const Center(child: Text('Checking...')),
),
),
);
}
}
class MyUpgradeAlert extends UpgradeAlert {
MyUpgradeAlert({super.key, super.upgrader, super.child});
/// Override the [createState] method to provide a custom class
/// with overridden methods.
@override
UpgradeAlertState createState() => MyUpgradeAlertState();
}
class MyUpgradeAlertState extends UpgradeAlertState {
@override
Widget alertDialog(
Key? key,
String title,
String message,
String? releaseNotes,
BuildContext context,
bool cupertino,
UpgraderMessages messages) {
return Theme(
data: ThemeData(
dialogTheme: const DialogThemeData(
titleTextStyle: TextStyle(color: Colors.red, fontSize: 48),
contentTextStyle: TextStyle(color: Colors.green, fontSize: 18),
),
textButtonTheme: const TextButtonThemeData(
style: ButtonStyle(
// Change the color of the text buttons.
foregroundColor: WidgetStatePropertyAll(Colors.orange),
),
),
),
child: super.alertDialog(
key, title, message, releaseNotes, context, cupertino, messages),
);
}
}