Я не могу повторить упомянутую вами проблему. событие onPress
срабатывает правильно и переходит к следующему экрану. Пример рабочего кода ниже:
return Scaffold(
backgroundColor: Colors.black,
body: Stack(
children: <Widget>[
Container(
height: 200,
width: 200,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/placeholder.png"),
fit: BoxFit.cover,
),
),
child: Padding(
padding: const EdgeInsets.only(top: 30, right: 20.0),
child: Align(
alignment: Alignment.topRight,
child: OutlineButton(
padding: EdgeInsets.only(left: 30, right: 30.0),
onPressed: () {
print("press");
Navigator.push(context,
MaterialPageRoute(builder: (context) => Safe()));
},
child: Text(
"SALTAR",
style: TextStyle(color: Colors.white),
),
borderSide: BorderSide(
color: Colors.white, style: BorderStyle.solid),
shape: StadiumBorder(),
)),
),
),
],
)
);
}
}
class Safe extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text('Test'),
),
);
}
}
Он правильно печатает вывод в консоли:
I/flutter ( 4357): press
I/flutter ( 4357): press
Вы можете сравнить свой код с приведенным выше и определить, чего вам не хватает в вашем коде.
Надеюсь, это поможет.