-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to Reproduce
Run the following code in release mode on Android devices:
import 'package:flutter/foundation.dart' show compute;
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Animal _animal;
int _count = 0;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Current animal is:',
),
Text(
'$_animal',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
_count++;
_animal = await compute(AnimalManage.getAnimal, _count % 3);
print('current _animal = $_animal, hashCode = ${_animal.hashCode}');
for (Animal animal in Animal.values) {
print('$animal : ${animal.hashCode}');
}
setState(() {});
},
tooltip: 'add',
child: Icon(Icons.add),
),
);
}
}
enum Animal {
dog,
fish,
cat,
}
class AnimalManage {
static Animal getAnimal(int arg) {
for (Animal animal in Animal.values) {
print('setAnimal: $animal, hashCode : ${animal.hashCode}');
}
return Animal.values[arg];
}
}
Expected results:
setAnimal: Animal.dog, hashCode : 577010217
setAnimal: Animal.fish, hashCode : 46727430
setAnimal: Animal.cat, hashCode : 1979930
current _animal = Animal.fish, hashCode = 46727430
Animal.dog : 577010217
Animal.fish : 46727430
Animal.cat : 1979930
Actual results:
setAnimal: Animal.dog, hashCode : 577010217
setAnimal: Animal.fish, hashCode : 46727430
setAnimal: Animal.cat, hashCode : 1979930
current _animal = Animal.fish, hashCode = 512740023 (expected 46727430)
Animal.dog : 217240488
Animal.fish : 513182005
Animal.cat : 671875267
Flutter version
Flutter 1.17.0 • channel unknown • unknown source
Framework • revision e6b34c2 (12 days ago) • 2020-05-02 11:39:18 -0700
Engine • revision 540786dd51
Tools • Dart 2.8.1