Skip to content

Commit 1b8dcb5

Browse files
Update button widgets in example app
Replacing deprecated FlatButton with TextButton.
1 parent eeb8ac9 commit 1b8dcb5

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

example/lib/main.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MyApp extends StatefulWidget {
1414

1515
class _MyAppState extends State<MyApp> {
1616
PDFDoc? _pdfDoc;
17-
String? _text = "";
17+
String _text = "";
1818

1919
bool _buttonsEnabled = true;
2020

@@ -35,32 +35,35 @@ class _MyAppState extends State<MyApp> {
3535
padding: EdgeInsets.all(10),
3636
child: ListView(
3737
children: <Widget>[
38-
FlatButton(
38+
TextButton(
3939
child: Text(
4040
"Pick PDF document",
4141
style: TextStyle(color: Colors.white),
4242
),
43-
color: Colors.blueAccent,
43+
style: TextButton.styleFrom(
44+
padding: EdgeInsets.all(5),
45+
backgroundColor: Colors.blueAccent),
4446
onPressed: _pickPDFText,
45-
padding: EdgeInsets.all(5),
4647
),
47-
FlatButton(
48+
TextButton(
4849
child: Text(
4950
"Read random page",
5051
style: TextStyle(color: Colors.white),
5152
),
52-
color: Colors.blueAccent,
53+
style: TextButton.styleFrom(
54+
padding: EdgeInsets.all(5),
55+
backgroundColor: Colors.blueAccent),
5356
onPressed: _buttonsEnabled ? _readRandomPage : () {},
54-
padding: EdgeInsets.all(5),
5557
),
56-
FlatButton(
58+
TextButton(
5759
child: Text(
5860
"Read whole document",
5961
style: TextStyle(color: Colors.white),
6062
),
61-
color: Colors.blueAccent,
63+
style: TextButton.styleFrom(
64+
padding: EdgeInsets.all(5),
65+
backgroundColor: Colors.blueAccent),
6266
onPressed: _buttonsEnabled ? _readWholeDoc : () {},
63-
padding: EdgeInsets.all(5),
6467
),
6568
Padding(
6669
child: Text(
@@ -80,7 +83,7 @@ class _MyAppState extends State<MyApp> {
8083
),
8184
padding: EdgeInsets.all(15),
8285
),
83-
Text(_text!),
86+
Text(_text),
8487
],
8588
),
8689
)),
@@ -105,7 +108,7 @@ class _MyAppState extends State<MyApp> {
105108
_buttonsEnabled = false;
106109
});
107110

108-
String? text =
111+
String text =
109112
await _pdfDoc!.pageAt(Random().nextInt(_pdfDoc!.length) + 1).text;
110113

111114
setState(() {

lib/client_provider.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:http/http.dart' show Client;
22

33
class ClientProvider {
4-
final Client _client;
4+
final Client _client;
55
static ClientProvider? _instance;
66

77
/// defaults to the standard dart http client
@@ -10,5 +10,5 @@ class ClientProvider {
1010
factory ClientProvider({Client? client}) =>
1111
_instance ?? (_instance = ClientProvider._create(client));
1212

13-
Client get client => _client;
14-
}
13+
Client get client => _client;
14+
}

0 commit comments

Comments
 (0)