mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Updated deprecated widgets with new one (#689)
This commit is contained in:
committed by
GitHub
parent
323c10558d
commit
d4f4065a6e
@@ -34,41 +34,37 @@ class _HomePageState extends State<HomePage> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text('Federated Plugin Demo'),
|
title: Text('Federated Plugin Demo'),
|
||||||
),
|
),
|
||||||
body: Builder(
|
body: Center(
|
||||||
builder: (context) {
|
child: Column(
|
||||||
return Center(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
child: Column(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
batteryLevel == null
|
||||||
children: [
|
? SizedBox.shrink()
|
||||||
batteryLevel == null
|
: Text(
|
||||||
? SizedBox.shrink()
|
'Battery Level: $batteryLevel',
|
||||||
: Text(
|
style: Theme.of(context).textTheme.headline5,
|
||||||
'Battery Level: $batteryLevel',
|
),
|
||||||
style: Theme.of(context).textTheme.headline5,
|
SizedBox(height: 16),
|
||||||
),
|
ElevatedButton(
|
||||||
SizedBox(height: 16),
|
child: Text('Get Battery Level'),
|
||||||
ElevatedButton(
|
onPressed: () async {
|
||||||
child: Text('Get Battery Level'),
|
try {
|
||||||
onPressed: () async {
|
final result = await getBatteryLevel();
|
||||||
try {
|
setState(() {
|
||||||
final result = await getBatteryLevel();
|
batteryLevel = result;
|
||||||
setState(() {
|
});
|
||||||
batteryLevel = result;
|
} catch (error) {
|
||||||
});
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
} catch (error) {
|
SnackBar(
|
||||||
Scaffold.of(context).showSnackBar(
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
SnackBar(
|
content: Text(error.message as String),
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
),
|
||||||
content: Text(error.message as String),
|
);
|
||||||
),
|
}
|
||||||
);
|
},
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,4 +212,4 @@ packages:
|
|||||||
version: "2.1.0-nullsafety.5"
|
version: "2.1.0-nullsafety.5"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.12.0-0.0 <3.0.0"
|
dart: ">=2.12.0-0.0 <3.0.0"
|
||||||
flutter: ">=1.20.0 <2.0.0"
|
flutter: ">=1.20.0"
|
||||||
|
|||||||
@@ -198,4 +198,4 @@ packages:
|
|||||||
version: "2.1.0-nullsafety.5"
|
version: "2.1.0-nullsafety.5"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.12.0-0.0 <3.0.0"
|
dart: ">=2.12.0-0.0 <3.0.0"
|
||||||
flutter: ">=1.20.0 <2.0.0"
|
flutter: ">=1.20.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user