Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_screenutil
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Mounir-Bouaiche
2022-05-01 21:23:28 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f50805e44198c4508d1d50e9f71328419b45827e
f50805e4
1 parent
d431baf8
Update example app
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
104 deletions
example/lib/main.dart
example/lib/src/second_method.dart
example/lib/src_zh/second_method.dart
example/lib/main.dart
View file @
f50805e
/*
import 'package:flutter/widgets.dart';
import
'package:flutter/widgets.dart'
;
import
'src/first_method.dart'
as
firstMethod
;
import
'src/second_method.dart'
as
secondMethod
;
...
...
@@ -6,106 +6,3 @@ void main() {
const
method
=
int
.
fromEnvironment
(
'method'
,
defaultValue:
1
);
runApp
(
method
==
1
?
firstMethod
.
MyApp
()
:
secondMethod
.
MyApp
());
}
*/
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
void
main
(
)
{
runApp
(
ScreenUtilInit
(
builder:
(
child
)
=>
MaterialApp
(
key:
GlobalObjectKey
(
'screenutil'
),
theme:
ThemeData
(
textTheme:
TextTheme
(
bodyText2:
TextStyle
(
fontSize:
32
.
sp
),
),
),
home:
child
,
),
child:
ThirdPage
(),
));
}
class
MyStatelessElement
<
T
extends
TestPage
>
extends
StatelessElement
{
MyStatelessElement
(
T
widget
)
:
super
(
widget
);
@override
T
get
widget
=>
super
.
widget
as
T
;
@override
void
mount
(
Element
?
parent
,
Object
?
newSlot
)
{
super
.
mount
(
parent
,
newSlot
);
print
(
'
${widget.text()}
is mounted'
);
}
@override
void
unmount
()
{
print
(
'
${widget.text()}
is unmounted'
);
super
.
unmount
();
}
}
abstract
class
TestPage
extends
StatelessWidget
{
String
text
()
=>
runtimeType
.
toString
();
Widget
goto
();
@override
StatelessElement
createElement
()
=>
MyStatelessElement
(
this
);
@override
Widget
build
(
BuildContext
context
)
{
Timer
(
const
Duration
(
seconds:
5
),
()
{
Navigator
.
of
(
context
).
pushAndRemoveUntil
(
MaterialPageRoute
(
builder:
(
context
)
=>
goto
()),
(
route
)
=>
false
,
);
});
return
Scaffold
(
body:
SafeArea
(
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
20
).
r
,
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
[
TextField
(),
Text
(
text
(),
style:
TextStyle
(
fontSize:
32
.
sp
),
),
Text
(
text
()),
Expanded
(
child:
ListView
.
separated
(
shrinkWrap:
true
,
itemBuilder:
(
context
,
index
)
=>
Text
(
'
$index
'
),
separatorBuilder:
(
_
,
__
)
=>
Container
(
height:
50
.
h
,
color:
Colors
.
green
,
),
itemCount:
10
,
),
),
],
),
),
),
);
}
}
class
FirstPage
extends
TestPage
{
@override
Widget
goto
()
=>
SecondPage
();
}
class
SecondPage
extends
TestPage
{
@override
Widget
goto
()
=>
FirstPage
();
}
class
ThirdPage
extends
TestPage
{
@override
Widget
goto
()
=>
FirstPage
();
}
...
...
example/lib/src/second_method.dart
View file @
f50805e
...
...
@@ -57,6 +57,7 @@ class MyThemedApp extends StatelessWidget {
debugShowCheckedModeBanner:
false
,
title:
'First Method (Themed)'
,
builder:
(
ctx
,
child
)
{
ScreenUtil
.
init
(
ctx
);
return
Theme
(
data:
ThemeData
(
primarySwatch:
Colors
.
blue
,
...
...
example/lib/src_zh/second_method.dart
View file @
f50805e
...
...
@@ -56,6 +56,7 @@ class MyThemedApp extends StatelessWidget {
debugShowCheckedModeBanner:
false
,
title:
'第二种方法(带主题)'
,
builder:
(
ctx
,
child
)
{
ScreenUtil
.
init
(
ctx
);
return
Theme
(
data:
ThemeData
(
primarySwatch:
Colors
.
blue
,
...
...
Please
register
or
login
to post a comment