-
Notifications
You must be signed in to change notification settings - Fork 158
Closed
Description
Run the following code on iPad simulator in landscape mode:
import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ResponsiveBreakpoints(
breakpoints: const [
Breakpoint(start: 0, end: 600, name: PHONE),
Breakpoint(start: 601, end: 900, name: TABLET),
Breakpoint(start: 901, end: double.infinity, name: DESKTOP),
],
useShortestSide: true,
landscapePlatforms: const [],
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
print(ResponsiveBreakpoints.of(context).breakpoint);
return const Placeholder();
}
}
Check the console, you should see the following output:
flutter: Breakpoint(start: 601.0, end: 900.0, name: TABLET)
Press home button to go back to home screen, the breakpoint is calculated again, you can validate that by seeing the following on console:
flutter: Breakpoint(start: 0.0, end: 600.0, name: PHONE)
Bring back the app, you can see the breakpoint is calculated again:
flutter: Breakpoint(start: 601.0, end: 900.0, name: TABLET)
Since the ResponsiveBreakpointsState
is already a WidgetsBindingObserver
, why don't we observe the AppLifecycleState
and calculate breakpoints only when the app is in foreground?
Related to this issue.
Metadata
Metadata
Assignees
Labels
No labels