李卓原

5.0.4 readme

1 # 5.0.4 1 # 5.0.4
2 - add setContext() , the first initialization method requires calling 2 - add setContext() , the first initialization method requires calling
3 - fix # 310 3 - fix # 310
  4 +- update ReadMe.md
4 5
5 # 5.0.3 6 # 5.0.3
6 7
@@ -92,10 +92,20 @@ class MyApp extends StatelessWidget { @@ -92,10 +92,20 @@ class MyApp extends StatelessWidget {
92 return ScreenUtilInit( 92 return ScreenUtilInit(
93 designSize: Size(360, 690), 93 designSize: Size(360, 690),
94 minTextAdapt: true, 94 minTextAdapt: true,
95 - builder: () => MaterialApp(  
96 - ... 95 + splitScreenMode: true,
  96 + builder: () =>
  97 + MaterialApp(
  98 + //... other code
  99 + builder: (context, widget) {
  100 + //add this line
  101 + ScreenUtil.setContext(context);
  102 + return MediaQuery(
  103 + //Setting font does not change with system font size
  104 + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  105 + child: widget,
  106 + );
  107 + },
97 theme: ThemeData( 108 theme: ThemeData(
98 - primarySwatch: Colors.blue,  
99 textTheme: TextTheme( 109 textTheme: TextTheme(
100 //To support the following, you need to use the first initialization method 110 //To support the following, you need to use the first initialization method
101 button: TextStyle(fontSize: 45.sp) 111 button: TextStyle(fontSize: 45.sp)
@@ -156,6 +166,7 @@ class _HomePageState extends State<HomePage> { @@ -156,6 +166,7 @@ class _HomePageState extends State<HomePage> {
156 maxWidth: MediaQuery.of(context).size.width, 166 maxWidth: MediaQuery.of(context).size.width,
157 maxHeight: MediaQuery.of(context).size.height), 167 maxHeight: MediaQuery.of(context).size.height),
158 designSize: Size(360, 690), 168 designSize: Size(360, 690),
  169 + context: context,
159 minTextAdapt: true, 170 minTextAdapt: true,
160 orientation: Orientation.portrait); 171 orientation: Orientation.portrait);
161 return Scaffold(); 172 return Scaffold();
@@ -63,17 +63,25 @@ class MyApp extends StatelessWidget { @@ -63,17 +63,25 @@ class MyApp extends StatelessWidget {
63 return ScreenUtilInit( 63 return ScreenUtilInit(
64 designSize: Size(360, 690), 64 designSize: Size(360, 690),
65 minTextAdapt: true, 65 minTextAdapt: true,
66 - builder: () => MaterialApp(  
67 - debugShowCheckedModeBanner: false,  
68 - title: 'Flutter_ScreenUtil', 66 + splitScreenMode: true,
  67 + builder: () =>
  68 + MaterialApp(
  69 + //... other code
  70 + builder: (context, widget) {
  71 + //add this line
  72 + ScreenUtil.setContext(context);
  73 + return MediaQuery(
  74 + //Setting font does not change with system font size
  75 + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  76 + child: widget,
  77 + );
  78 + },
69 theme: ThemeData( 79 theme: ThemeData(
70 - primarySwatch: Colors.blue,  
71 - //要支持下面这个需要使用第一种初始化方式  
72 textTheme: TextTheme( 80 textTheme: TextTheme(
  81 + //要支持下面这个需要使用第一种初始化方式
73 button: TextStyle(fontSize: 45.sp) 82 button: TextStyle(fontSize: 45.sp)
74 ), 83 ),
75 ), 84 ),
76 - home: HomePage(title: 'FlutterScreenUtil Demo'),  
77 ), 85 ),
78 ); 86 );
79 } 87 }
@@ -118,6 +126,7 @@ class _HomePageState extends State<HomePage> { @@ -118,6 +126,7 @@ class _HomePageState extends State<HomePage> {
118 maxWidth: MediaQuery.of(context).size.width, 126 maxWidth: MediaQuery.of(context).size.width,
119 maxHeight: MediaQuery.of(context).size.height), 127 maxHeight: MediaQuery.of(context).size.height),
120 designSize: Size(360, 690), 128 designSize: Size(360, 690),
  129 + context: context,
121 minTextAdapt: true, 130 minTextAdapt: true,
122 orientation: Orientation.portrait); 131 orientation: Orientation.portrait);
123 return Scaffold(); 132 return Scaffold();
@@ -59,12 +59,22 @@ class MyApp extends StatelessWidget { @@ -59,12 +59,22 @@ class MyApp extends StatelessWidget {
59 return ScreenUtilInit( 59 return ScreenUtilInit(
60 designSize: Size(360, 690), 60 designSize: Size(360, 690),
61 minTextAdapt: true, 61 minTextAdapt: true,
62 - builder: () => MaterialApp(  
63 - ... 62 + splitScreenMode: true,
  63 + builder: () =>
  64 + MaterialApp(
  65 + //... other code
  66 + builder: (context, widget) {
  67 + //add this line
  68 + ScreenUtil.setContext(context);
  69 + return MediaQuery(
  70 + //Setting font does not change with system font size
  71 + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
  72 + child: widget,
  73 + );
  74 + },
64 theme: ThemeData( 75 theme: ThemeData(
65 - primarySwatch: Colors.blue,  
66 - //To support the following, you need to use the first initialization method  
67 textTheme: TextTheme( 76 textTheme: TextTheme(
  77 + //To support the following, you need to use the first initialization method
68 button: TextStyle(fontSize: 45.sp) 78 button: TextStyle(fontSize: 45.sp)
69 ), 79 ),
70 ), 80 ),
@@ -108,6 +118,7 @@ class _HomePageState extends State<HomePage> { @@ -108,6 +118,7 @@ class _HomePageState extends State<HomePage> {
108 maxWidth: MediaQuery.of(context).size.width, 118 maxWidth: MediaQuery.of(context).size.width,
109 maxHeight: MediaQuery.of(context).size.height), 119 maxHeight: MediaQuery.of(context).size.height),
110 designSize: Size(360, 690), 120 designSize: Size(360, 690),
  121 + context: context,
111 orientation: Orientation.portrait); 122 orientation: Orientation.portrait);
112 return Scaffold(); 123 return Scaffold();
113 } 124 }