Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
CHILD INTELLIGENT ASSESSMENT TOOL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-046
CHILD INTELLIGENT ASSESSMENT TOOL
Commits
595ab1eb
Commit
595ab1eb
authored
Oct 28, 2020
by
Dasun Madushanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload painter view interface
parent
9d6af37e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
184 additions
and
0 deletions
+184
-0
MainAppDMT/lib/screens/Painter/painter_view.dart
MainAppDMT/lib/screens/Painter/painter_view.dart
+184
-0
No files found.
MainAppDMT/lib/screens/Painter/painter_view.dart
0 → 100644
View file @
595ab1eb
import
'package:flutter/material.dart'
;
import
'package:painter2/painter2.dart'
;
import
'dart:typed_data'
;
class
ExamplePage
extends
StatefulWidget
{
@override
_ExamplePageState
createState
()
=>
new
_ExamplePageState
();
}
class
_ExamplePageState
extends
State
<
ExamplePage
>
{
bool
_finished
;
PainterController
_controller
;
@override
void
initState
()
{
super
.
initState
();
_finished
=
false
;
_controller
=
newController
();
}
PainterController
newController
()
{
PainterController
controller
=
PainterController
();
controller
.
thickness
=
5.0
;
controller
.
backgroundColor
=
Colors
.
green
;
controller
.
backgroundImage
=
Image
.
network
(
'https://cdn-images-1.medium.com/max/1200/1*5-aoK8IBmXve5whBQM90GA.png'
);
return
controller
;
}
@override
Widget
build
(
BuildContext
context
)
{
List
<
Widget
>
actions
;
if
(
_finished
)
{
actions
=
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
content_copy
),
tooltip:
'New Painting'
,
onPressed:
()
=>
setState
(()
{
_finished
=
false
;
_controller
=
newController
();
}),
),
];
}
else
{
actions
=
<
Widget
>[
IconButton
(
icon:
Icon
(
Icons
.
undo
),
tooltip:
'Undo'
,
onPressed:
()
{
if
(
_controller
.
canUndo
)
_controller
.
undo
();
},
),
IconButton
(
icon:
Icon
(
Icons
.
redo
),
tooltip:
'Redo'
,
onPressed:
()
{
if
(
_controller
.
canRedo
)
_controller
.
redo
();
},
),
IconButton
(
icon:
Icon
(
Icons
.
delete
),
tooltip:
'Clear'
,
onPressed:
()
=>
_controller
.
clear
(),
),
IconButton
(
icon:
Icon
(
Icons
.
check
),
onPressed:
()
async
{
setState
(()
{
_finished
=
true
;
});
Uint8List
bytes
=
await
_controller
.
exportAsPNGBytes
();
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'View your image'
),
),
body:
Container
(
child:
Image
.
memory
(
bytes
),
),
);
}));
}),
];
}
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Painter2 Example'
),
actions:
actions
,
bottom:
PreferredSize
(
child:
DrawBar
(
_controller
),
preferredSize:
Size
(
MediaQuery
.
of
(
context
).
size
.
width
,
30.0
),
)),
body:
Center
(
child:
AspectRatio
(
aspectRatio:
1.0
,
child:
Painter
(
_controller
))),
);
}
}
class
DrawBar
extends
StatelessWidget
{
final
PainterController
_controller
;
DrawBar
(
this
.
_controller
);
@override
Widget
build
(
BuildContext
context
)
{
return
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Flexible
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Container
(
child:
Slider
(
value:
_controller
.
thickness
,
onChanged:
(
value
)
=>
setState
(()
{
_controller
.
thickness
=
value
;
}),
min:
1.0
,
max:
20.0
,
activeColor:
Colors
.
white
,
));
})),
ColorPickerButton
(
_controller
,
false
),
ColorPickerButton
(
_controller
,
true
),
],
);
}
}
class
ColorPickerButton
extends
StatefulWidget
{
final
PainterController
_controller
;
final
bool
_background
;
ColorPickerButton
(
this
.
_controller
,
this
.
_background
);
@override
_ColorPickerButtonState
createState
()
=>
new
_ColorPickerButtonState
();
}
class
_ColorPickerButtonState
extends
State
<
ColorPickerButton
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
IconButton
(
icon:
Icon
(
_iconData
,
color:
_color
),
tooltip:
widget
.
_background
?
'Change background color'
:
'Change draw color'
,
onPressed:
()
=>
_pickColor
(),
);
}
void
_pickColor
()
{
Color
pickerColor
=
_color
;
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
fullscreenDialog:
true
,
builder:
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Pick color'
),
),
body:
Container
());
}))
.
then
((
_
)
{
setState
(()
{
_color
=
pickerColor
;
});
});
}
Color
get
_color
=>
widget
.
_background
?
widget
.
_controller
.
backgroundColor
:
widget
.
_controller
.
drawColor
;
IconData
get
_iconData
=>
widget
.
_background
?
Icons
.
format_color_fill
:
Icons
.
brush
;
set
_color
(
Color
color
)
{
if
(
widget
.
_background
)
{
widget
.
_controller
.
backgroundColor
=
color
;
}
else
{
widget
.
_controller
.
drawColor
=
color
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment