1
1
import 'package:flutter/material.dart' ;
2
- import 'package:image_picker/image_picker.dart' ;
3
2
4
3
class AddBlog extends StatefulWidget {
5
4
AddBlog ({Key key}) : super (key: key);
@@ -9,108 +8,108 @@ class AddBlog extends StatefulWidget {
9
8
}
10
9
11
10
class _AddBlogState extends State <AddBlog > {
12
- PickedFile _imageFile;
13
- final ImagePicker _picker = ImagePicker ();
14
- IconData icon = Icons .image;
15
11
@override
16
12
Widget build (BuildContext context) {
17
13
return Scaffold (
18
14
appBar: AppBar (
19
- elevation: 0 ,
20
15
backgroundColor: Colors .white54,
16
+ elevation: 0 ,
21
17
leading: IconButton (icon: Icon (Icons .clear), onPressed: null ),
22
18
actions: < Widget > [
23
- Padding (
24
- padding: const EdgeInsets .all (8.0 ),
25
- child: FlatButton (
26
- onPressed: null ,
27
- child: Text (
28
- "Submit" ,
29
- style: TextStyle (color: Colors .teal, fontSize: 20 ),
30
- )),
31
- )
19
+ FlatButton (
20
+ onPressed: null ,
21
+ child: Text (
22
+ "Preview" ,
23
+ style: TextStyle (fontSize: 18 , color: Colors .blue),
24
+ ))
32
25
],
33
26
),
34
- body: SingleChildScrollView (
35
- child: Column (
36
- children: < Widget > [
37
- textField (),
38
- textField2 (),
39
- ],
40
- ),
27
+ body: ListView (
28
+ children: < Widget > [
29
+ titleTextField (),
30
+ bodyTextField (),
31
+ SizedBox (
32
+ height: 20 ,
33
+ ),
34
+ addButton (),
35
+ ],
41
36
),
42
37
);
43
38
}
44
39
45
- Widget textField () {
40
+ Widget titleTextField () {
46
41
return Padding (
47
- padding: const EdgeInsets .symmetric (horizontal: 10 , vertical: 10 ),
42
+ padding: const EdgeInsets .symmetric (
43
+ horizontal: 10 ,
44
+ vertical: 10 ,
45
+ ),
48
46
child: TextFormField (
49
- // controller: _name,
50
- validator: (value) {
51
- if (value.isEmpty) return "Name can't be empty" ;
52
-
53
- return null ;
54
- },
55
- maxLength: 100 ,
56
- maxLines: null ,
57
47
decoration: InputDecoration (
58
- prefixIcon: IconButton (
59
- icon: Icon (
60
- icon,
61
- color: Colors .green,
62
- ),
63
- onPressed: takePhoto),
64
48
border: OutlineInputBorder (
65
- borderSide: BorderSide (
66
- color: Colors .teal,
67
- )),
49
+ borderSide: BorderSide (
50
+ color: Colors .teal,
51
+ ),
52
+ ),
68
53
focusedBorder: OutlineInputBorder (
69
- borderSide: BorderSide (
70
- color: Colors .orange,
71
- width: 2 ,
72
- )),
73
- labelText: "Cover Image and Title" ,
54
+ borderSide: BorderSide (
55
+ color: Colors .orange,
56
+ width: 2 ,
57
+ ),
58
+ ),
59
+ labelText: "Add Image and Title" ,
60
+ prefixIcon: IconButton (
61
+ icon: Icon (
62
+ Icons .image,
63
+ color: Colors .teal,
64
+ ),
65
+ onPressed: null ,
66
+ ),
74
67
),
68
+ maxLength: 100 ,
69
+ maxLines: null ,
75
70
),
76
71
);
77
72
}
78
73
79
- Widget textField2 () {
74
+ Widget bodyTextField () {
80
75
return Padding (
81
- padding: const EdgeInsets .symmetric (horizontal: 10 , vertical: 10 ),
76
+ padding: const EdgeInsets .symmetric (
77
+ horizontal: 10 ,
78
+ ),
82
79
child: TextFormField (
83
- // controller: _name,
84
- validator: (value) {
85
- if (value.isEmpty) return "Name can't be empty" ;
86
-
87
- return null ;
88
- },
89
- // maxLength: 100,
90
- maxLines: null ,
91
80
decoration: InputDecoration (
92
81
border: OutlineInputBorder (
93
- borderSide: BorderSide (
94
- color: Colors .teal,
95
- )),
82
+ borderSide: BorderSide (
83
+ color: Colors .teal,
84
+ ),
85
+ ),
96
86
focusedBorder: OutlineInputBorder (
97
- borderSide: BorderSide (
98
- color: Colors .orange,
99
- width: 2 ,
100
- )),
101
- labelText: "body" ,
87
+ borderSide: BorderSide (
88
+ color: Colors .orange,
89
+ width: 2 ,
90
+ ),
91
+ ),
92
+ labelText: "Provide Body Your Blog" ,
102
93
),
94
+ maxLines: null ,
103
95
),
104
96
);
105
97
}
106
98
107
- void takePhoto () async {
108
- final pickedFile = await _picker.getImage (
109
- source: ImageSource .gallery,
99
+ Widget addButton () {
100
+ return Center (
101
+ child: Container (
102
+ height: 50 ,
103
+ width: 200 ,
104
+ decoration: BoxDecoration (
105
+ borderRadius: BorderRadius .circular (10 ), color: Colors .teal),
106
+ child: Center (
107
+ child: Text (
108
+ "Add Blog" ,
109
+ style: TextStyle (
110
+ color: Colors .white, fontSize: 16 , fontWeight: FontWeight .bold),
111
+ )),
112
+ ),
110
113
);
111
- setState (() {
112
- _imageFile = pickedFile;
113
- icon = Icons .check_box;
114
- });
115
114
}
116
115
}
0 commit comments