1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:m_loading/m_loading.dart' ;
2
3
3
4
void main () {
4
5
runApp (MyApp ());
@@ -11,107 +12,130 @@ class MyApp extends StatelessWidget {
11
12
return MaterialApp (
12
13
title: 'Flutter Demo' ,
13
14
theme: ThemeData (
14
- // This is the theme of your application.
15
- //
16
- // Try running your application with "flutter run". You'll see the
17
- // application has a blue toolbar. Then, without quitting the app, try
18
- // changing the primarySwatch below to Colors.green and then invoke
19
- // "hot reload" (press "r" in the console where you ran "flutter run",
20
- // or simply save your changes to "hot reload" in a Flutter IDE).
21
- // Notice that the counter didn't reset back to zero; the application
22
- // is not restarted.
23
15
primarySwatch: Colors .blue,
24
- // This makes the visual density adapt to the platform that you run
25
- // the app on. For desktop platforms, the controls will be smaller and
26
- // closer together (more dense) than on mobile platforms.
27
16
visualDensity: VisualDensity .adaptivePlatformDensity,
28
17
),
29
- home: MyHomePage (title: 'Flutter Demo Home Page ' ),
18
+ home: MyHomePage (title: 'MLoading Demo' ),
30
19
);
31
20
}
32
21
}
33
22
34
23
class MyHomePage extends StatefulWidget {
35
24
MyHomePage ({Key key, this .title}) : super (key: key);
36
25
37
- // This widget is the home page of your application. It is stateful, meaning
38
- // that it has a State object (defined below) that contains fields that affect
39
- // how it looks.
40
-
41
- // This class is the configuration for the state. It holds the values (in this
42
- // case the title) provided by the parent (in this case the App widget) and
43
- // used by the build method of the State. Fields in a Widget subclass are
44
- // always marked "final".
45
-
46
26
final String title;
47
27
48
28
@override
49
29
_MyHomePageState createState () => _MyHomePageState ();
50
30
}
51
31
52
32
class _MyHomePageState extends State <MyHomePage > {
53
- int _counter = 0 ;
54
33
55
- void _incrementCounter () {
56
- setState (() {
57
- // This call to setState tells the Flutter framework that something has
58
- // changed in this State, which causes it to rerun the build method below
59
- // so that the display can reflect the updated values. If we changed
60
- // _counter without calling setState(), then the build method would not be
61
- // called again, and so nothing would appear to happen.
62
- _counter++ ;
63
- });
64
- }
65
34
66
35
@override
67
36
Widget build (BuildContext context) {
68
- // This method is rerun every time setState is called, for instance as done
69
- // by the _incrementCounter method above.
70
- //
71
- // The Flutter framework has been optimized to make rerunning build methods
72
- // fast, so that you can just rebuild anything that needs updating rather
73
- // than having to individually change instances of widgets.
37
+ Color _color = Theme .of (context).primaryColor;
38
+ Duration _duration = Duration (seconds: 10 );
39
+ Curve _curve = Curves .bounceIn;
40
+
41
+ BallStyle _ballStyle= BallStyle (
42
+ color: _color,
43
+ );
44
+
74
45
return Scaffold (
75
46
appBar: AppBar (
76
- // Here we take the value from the MyHomePage object that was created by
77
- // the App.build method, and use it to set our appbar title.
78
47
title: Text (widget.title),
79
48
),
80
- body: Center (
81
- // Center is a layout widget. It takes a single child and positions it
82
- // in the middle of the parent.
83
- child: Column (
84
- // Column is also a layout widget. It takes a list of children and
85
- // arranges them vertically. By default, it sizes itself to fit its
86
- // children horizontally, and tries to be as tall as its parent.
87
- //
88
- // Invoke "debug painting" (press "p" in the console, choose the
89
- // "Toggle Debug Paint" action from the Flutter Inspector in Android
90
- // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
91
- // to see the wireframe for each widget.
92
- //
93
- // Column has various properties to control how it sizes itself and
94
- // how it positions its children. Here we use mainAxisAlignment to
95
- // center the children vertically; the main axis here is the vertical
96
- // axis because Columns are vertical (the cross axis would be
97
- // horizontal).
98
- mainAxisAlignment: MainAxisAlignment .center,
99
- children: < Widget > [
100
- Text (
101
- 'You have pushed the button this many times:' ,
102
- ),
103
- Text (
104
- '$_counter ' ,
105
- style: Theme .of (context).textTheme.headline4,
49
+ // backgroundColor: Color(0xFFBBDEFB),
50
+ body: GridView (
51
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount (
52
+ crossAxisCount: 4 ,
53
+ ),
54
+ children: [
55
+ _item (BallPulseLoading (ballStyle: _ballStyle,)),
56
+ _item (Ball4ScaleLoading (ballStyle: _ballStyle,)),
57
+ _item (BallGridPulseLoading (ballStyle: _ballStyle,)),
58
+ _item (BallCirclePulseLoading (ballStyle: _ballStyle,)),
59
+ _item (Ball3OpacityLoading (ballStyle: _ballStyle,)),
60
+ _item (Ball4OpacityLoading (ballStyle: _ballStyle,)),
61
+ _item (BallGridOpacityLoading (ballStyle: _ballStyle,)),
62
+ _item (BallCircleRotateLoading (ballStyle: _ballStyle,)),
63
+ _item (BallBounceLoading (ballStyle: _ballStyle,)),
64
+ _item (BallRotateScaleLoading (ballStyle: _ballStyle,)),
65
+ _item (Ball2TrianglePathLoading (ballStyle: _ballStyle,), width: 40 , height: 40 ),
66
+ _item (BallCircleOpacityLoading (ballStyle: _ballStyle,), width: 40 , height: 40 ),
67
+ _item (Ball3TrianglePathLoading (ballStyle: _ballStyle,)),
68
+ _item (BallInsideBallLoading (ballStyle: _ballStyle,backgroundColor: _color.withOpacity (0.3 ),), width: 40 , height: 40 ),
69
+ _item (BallClipRotatePulseLoading (ballStyle: _ballStyle,ringColor: _color,), width: 40 , height: 40 ),
70
+
71
+ _item (BallCircleInsideRotateLoading (ballStyle: _ballStyle,), width: 40 , height: 40 ),
72
+
73
+ _item (RingRotate (color: _color,), width: 40 , height: 40 ),
74
+ _item (Ring2InsideLoading (color: _color,), width: 40 , height: 40 ),
75
+ _item (Ring2SymmetryLoading (color: _color,), width: 40 , height: 40 ),
76
+ _item (RingBallRotateLoading (ballColor: _color,circleColor: _color.withOpacity (0.3 ),), width: 40 , height: 40 ),
77
+ _item (RingClipRotateMultiple (innerColor: _color,outerColor: _color,), width: 40 , height: 40 ),
78
+ _item (WaterCircleLoading (color: _color,)),
79
+ _item (Water2CircleLoading (color: _color,)),
80
+ _item (WaterRipple (color: _color,)),
81
+ _item (WaterMultipleCircleLoading (color: _color,)),
82
+ _item (WaterPulseLoading (color: _color,)),
83
+ _item (BarPulseLoading (color: _color,), width: 40 , height: 40 ),
84
+ _item (BarScaleLoading (color: _color,), width: 40 , height: 40 ),
85
+ _item (BarScale1Loading (color: _color,), width: 40 , height: 40 ),
86
+ _item (BarScalePulseOutLoading (color: _color,), width: 40 , height: 40 ),
87
+ _item (BarMusicLoading (color: _color,), width: 26 , height: 40 ),
88
+ // _item(Square4RotateLoading(color: _color,)),
89
+ _item (Square4OpacityLoading (color: _color,), width: 40 , height: 40 ),
90
+ _item (SquareFadingLoading (color: _color,), width: 40 , height: 40 ),
91
+ _item (SquareRotateLoading (color: _color,), width: 40 , height: 40 ),
92
+ _item (SquareGridScaleLoading (color: _color,)),
93
+ _item (CircleRotateLoading (color: _color,), width: 40 , height: 40 ),
94
+ _item (CirclePulseLoading (color: _color,), width: 40 , height: 40 ),
95
+ _item (
96
+ CircleSquareLoading (
97
+ size: 30 ,
98
+ color: _color,
99
+ ),
100
+ width: 30 ,
101
+ height: 30 ),
102
+ _item (Circle2InsideScaleLoading (smallCircleColor: _color,), width: 40 , height: 40 ),
103
+ _item (PouringHourGlassLoading (color: _color,), width: 30 , height: 40 ),
104
+ _item (PacmanLoading (mouthColor: _color,ballColor: _color,), width: 80 , height: 40 ),
105
+ ],
106
+ ),
107
+ );
108
+ }
109
+
110
+ _item (
111
+ Widget loading, {
112
+ double width = 60 ,
113
+ double height = 60 ,
114
+ }) {
115
+ return GestureDetector (
116
+ behavior: HitTestBehavior .opaque,
117
+ onTap: () {
118
+ Navigator .of (context)
119
+ .push (MaterialPageRoute (builder: (BuildContext context) {
120
+ return Scaffold (
121
+ appBar: AppBar (),
122
+ body: Center (
123
+ child: Container (
124
+ height: height,
125
+ width: width,
126
+ child: loading,
127
+ ),
106
128
),
107
- ],
129
+ );
130
+ }));
131
+ },
132
+ child: Center (
133
+ child: Container (
134
+ height: height,
135
+ width: width,
136
+ child: loading,
108
137
),
109
138
),
110
- floatingActionButton: FloatingActionButton (
111
- onPressed: _incrementCounter,
112
- tooltip: 'Increment' ,
113
- child: Icon (Icons .add),
114
- ), // This trailing comma makes auto-formatting nicer for build methods.
115
139
);
116
140
}
117
141
}
0 commit comments