mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Update for Flutter 3.10 beta (#1746)
## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] All existing and new tests are passing. --------- Co-authored-by: David Iglesias <ditman@gmail.com> Co-authored-by: Mark Thompson <2554588+MarkTechson@users.noreply.github.com> Co-authored-by: John Ryan <ryjohn@google.com>
This commit is contained in:
@@ -60,25 +60,31 @@ class DataTransferPage extends StatelessWidget {
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: (controller.runningTest == 1)
|
||||
? Colors.blueAccent
|
||||
: Colors.blueGrey),
|
||||
foregroundColor: switch (controller.runningTest) {
|
||||
1 => Colors.blueAccent,
|
||||
_ => Colors.blueGrey,
|
||||
},
|
||||
),
|
||||
onPressed: () => controller.generateRandomNumbers(false),
|
||||
child: const Text('Transfer Data to 2nd Isolate'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: (controller.runningTest == 2)
|
||||
? Colors.blueAccent
|
||||
: Colors.blueGrey),
|
||||
foregroundColor: switch (controller.runningTest) {
|
||||
2 => Colors.blueAccent,
|
||||
_ => Colors.blueGrey,
|
||||
},
|
||||
),
|
||||
onPressed: () => controller.generateRandomNumbers(true),
|
||||
child: const Text('Transfer Data with TransferableTypedData'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: (controller.runningTest == 3)
|
||||
? Colors.blueAccent
|
||||
: Colors.blueGrey),
|
||||
foregroundColor: switch (controller.runningTest) {
|
||||
3 => Colors.blueAccent,
|
||||
_ => Colors.blueGrey,
|
||||
},
|
||||
),
|
||||
onPressed: controller.generateOnSecondaryIsolate,
|
||||
child: const Text('Generate on 2nd Isolate'),
|
||||
),
|
||||
@@ -115,19 +121,16 @@ class DataTransferIsolateController extends ChangeNotifier {
|
||||
|
||||
void listen() {
|
||||
_incomingReceivePort.listen((dynamic message) {
|
||||
if (message is SendPort) {
|
||||
_outgoingSendPort = message;
|
||||
}
|
||||
|
||||
if (message is int) {
|
||||
currentProgress.insert(
|
||||
0, '$message% - ${_timer.elapsedMilliseconds / 1000} seconds');
|
||||
progressPercent = message / 100;
|
||||
}
|
||||
|
||||
if (message is String && message == 'done') {
|
||||
runningTest = 0;
|
||||
_timer.stop();
|
||||
switch (message) {
|
||||
case SendPort():
|
||||
_outgoingSendPort = message;
|
||||
case int():
|
||||
currentProgress.insert(
|
||||
0, '$message% - ${_timer.elapsedMilliseconds / 1000} seconds');
|
||||
progressPercent = message / 100;
|
||||
case 'done':
|
||||
runningTest = 0;
|
||||
_timer.stop();
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
@@ -131,11 +131,12 @@ class InfiniteProcessIsolateController extends ChangeNotifier {
|
||||
|
||||
void listen() {
|
||||
receivePort.listen((dynamic message) {
|
||||
if (message is SendPort) {
|
||||
newIceSP = message;
|
||||
newIceSP.send(_currentMultiplier);
|
||||
} else if (message is int) {
|
||||
setCurrentResults(message);
|
||||
switch (message) {
|
||||
case SendPort():
|
||||
newIceSP = message;
|
||||
newIceSP.send(_currentMultiplier);
|
||||
case int():
|
||||
setCurrentResults(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,10 +56,11 @@ class _PerformancePageState extends State<PerformancePage> {
|
||||
builder: (context, snapshot) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(elevation: 8.0),
|
||||
onPressed:
|
||||
snapshot.connectionState == ConnectionState.done
|
||||
? () => handleComputeOnMain(context)
|
||||
: null,
|
||||
onPressed: switch (snapshot.connectionState) {
|
||||
ConnectionState.done => () =>
|
||||
handleComputeOnMain(context),
|
||||
_ => null
|
||||
},
|
||||
child: const Text('Compute on Main'),
|
||||
);
|
||||
},
|
||||
@@ -69,10 +70,11 @@ class _PerformancePageState extends State<PerformancePage> {
|
||||
builder: (context, snapshot) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(elevation: 8.0),
|
||||
onPressed:
|
||||
snapshot.connectionState == ConnectionState.done
|
||||
? () => handleComputeOnSecondary(context)
|
||||
: null,
|
||||
onPressed: switch (snapshot.connectionState) {
|
||||
ConnectionState.done => () =>
|
||||
handleComputeOnSecondary(context),
|
||||
_ => null
|
||||
},
|
||||
child: const Text('Compute on Secondary'));
|
||||
},
|
||||
),
|
||||
|
||||
@@ -4,7 +4,7 @@ version: 1.0.0+1
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: '>=2.19.5 <4.0.0'
|
||||
sdk: ^3.0.0-0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
||||
Reference in New Issue
Block a user