李卓原

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,16 +92,26 @@ class MyApp extends StatelessWidget { @@ -92,16 +92,26 @@ 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 - ...  
97 - theme: ThemeData(  
98 - primarySwatch: Colors.blue,  
99 - textTheme: TextTheme(  
100 - //To support the following, you need to use the first initialization method  
101 - button: TextStyle(fontSize: 45.sp)  
102 - ),  
103 - ),  
104 - ), 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 + },
  108 + theme: ThemeData(
  109 + textTheme: TextTheme(
  110 + //To support the following, you need to use the first initialization method
  111 + button: TextStyle(fontSize: 45.sp)
  112 + ),
  113 + ),
  114 + ),
105 ); 115 );
106 } 116 }
107 } 117 }
@@ -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,18 +63,26 @@ class MyApp extends StatelessWidget { @@ -63,18 +63,26 @@ 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',  
69 - theme: ThemeData(  
70 - primarySwatch: Colors.blue,  
71 - //要支持下面这个需要使用第一种初始化方式  
72 - textTheme: TextTheme(  
73 - button: TextStyle(fontSize: 45.sp)  
74 - ),  
75 - ),  
76 - home: HomePage(title: 'FlutterScreenUtil Demo'),  
77 - ), 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 + },
  79 + theme: ThemeData(
  80 + textTheme: TextTheme(
  81 + //要支持下面这个需要使用第一种初始化方式
  82 + button: TextStyle(fontSize: 45.sp)
  83 + ),
  84 + ),
  85 + ),
78 ); 86 );
79 } 87 }
80 } 88 }
@@ -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,16 +59,26 @@ class MyApp extends StatelessWidget { @@ -59,16 +59,26 @@ 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 - ...  
64 - theme: ThemeData(  
65 - primarySwatch: Colors.blue,  
66 - //To support the following, you need to use the first initialization method  
67 - textTheme: TextTheme(  
68 - button: TextStyle(fontSize: 45.sp)  
69 - ),  
70 - ),  
71 - ), 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 + },
  75 + theme: ThemeData(
  76 + textTheme: TextTheme(
  77 + //To support the following, you need to use the first initialization method
  78 + button: TextStyle(fontSize: 45.sp)
  79 + ),
  80 + ),
  81 + ),
72 ); 82 );
73 } 83 }
74 } 84 }
@@ -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 }