Flutter navigate with an ElevatedButton to another side of CurvedNavigationBar - flutter

I use the CurvedNavigationBar V1.0.3 to navigate between 5 sides. each of them has an extra dart file. The bottombar is in my main.dart.
I want to use a button in /body which leads to another side and change also to the right icon in bottombar.
main.dart
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'Pages/Beritpage.dart';
import 'Pages/donepage.dart';
import 'Pages/settingspage.dart';
import 'Pages/tinapage.dart';
import 'Pages/assmapage.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
static final String title = 'Curved Navigation Bar';
const MyApp({super.key});
#override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
home: MainPage(),
);
}
class MainPage extends StatefulWidget {
#override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
final navigationKey = GlobalKey<CurvedNavigationBarState>();
int index = 2;
final screens = [
AssmaPage(),
BeritPage(),
TinaPage(),
SettingsPage(),
DonePage(),
];
#override
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
final items = <Widget>[
Icon(Icons.mediation, size: 30),
Icon(Icons.donut_small, size: 30),
Icon(Icons.home, size: 30),
Icon(Icons.settings, size: 30),
Icon(Icons.done, size: 30),
];
// SafeArea and Cliptrect für IOS
return Container(
color: Color(0xFF145246),
child: SafeArea(
top: false,
child: ClipRect(
child: Scaffold(
extendBody: true,
// Topbar Start
appBar: AppBar(
toolbarHeight: 80,
// Set this height
leading: Icon(Icons.account_circle_rounded),
centerTitle: true,
title: SizedBox(
width: 70,
child: Image.network('https://i.ibb.co/c8ZvGYC/New.png'),
),
//actions: <Widget>[
//Padding(
//padding: EdgeInsets.only(right: 20.0),
//child: GestureDetector(
//onTap: () {},
//child: Icon(
//Icons.,
//size: 26.0,
//),
//)),
//],"
flexibleSpace: Container(
color: Color(0xFF145246),
//child: Column(
//children: [
//Text('One'),
//Text('Two'),
//],
//),
),
),
//Drawer Start
endDrawer: Container(
height: screenHeight,
width: screenWidth * 0.7,
color: Color(0xFF145246)),
//Drawer Ende
//Topbar Ende
body: screens[index],
//Bottombar Start
bottomNavigationBar: Theme(
data: Theme.of(context).copyWith(
iconTheme: IconThemeData(color: Colors.white),
),
child: CurvedNavigationBar(
key: navigationKey,
color: Color(0xFF145246),
buttonBackgroundColor: Color(0xFF145246),
backgroundColor: Colors.transparent,
height: 60,
animationCurve: Curves.easeInOut,
animationDuration: Duration(milliseconds: 300),
index: index,
items: items,
onTap: (index) => setState(() => this.index = index),
),
//Bottombar Ende
),
),
),
),
);
}
}
The recommended way is
final navigationState = navigationKey.currentState!;
navigationState.setPage(0);
but that only seems working, when i have the screens in the same dart file.
i tried to put the code in one of my page files but then i get a
"_CastError (Null check operator used on a null value)"
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'beritpage.dart';
import 'donepage.dart';
import 'settingspage.dart';
import 'tinapage.dart';
import 'assmapage.dart';
import 'package:test_app/main.dart';
class TinaPage extends StatelessWidget {
#override
Widget build(BuildContext context) => Scaffold(
backgroundColor: Color(0xFFB1C5AD),
body: Center(
//Aenderung Hermann
child: Column(
children: <Widget>[
SizedBox(
width: 400,
height: 70,
child: Center(
child: Text('Material'),
),
),
SizedBox(
width: 300,
height: 200,
child: Center(
child: Image.asset('assets/T-Shirt.png'),
),
),
SizedBox(
width: 200,
height: 70,
child: Center(
child: Text('Artikel-Nr.: 1062053001 '),
),
),
SizedBox(
height: 30,
),
ElevatedButton(
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
backgroundColor: Color(0xFF145245),
),
onPressed: () {
final navigationState = navigationKey.currentState!;
navigationState.setPage(0);
},
child: const Text('Cotton')),
SizedBox(
height: 30,
),
ElevatedButton(
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
backgroundColor: Color(0xFF145245),
),
onPressed: () {},
child: const Text('Viskose')),
SizedBox(
height: 30,
),
ElevatedButton(
style: ElevatedButton.styleFrom(
shape: const StadiumBorder(),
backgroundColor: Color(0xFF145245),
),
onPressed: () {},
child: const Text('Elastan')),
],
),
),
);
}
I also tried Navigation.push to another side. but then i lose the Appbar and Buttonbar which are defined in main.dart.
I wanted to press the button "Cotton" and move to "AssmaPage" and see the first icon in Bottombar is highlighted.

Related

Is there any way to put custom toolbar on the keypad?

I want to put a custom toolbar on the keypad like the image above. Is it possible in flutter? or should I write code on the iOS or Android side?
You can copy paste run full code below
Please see working demo below
You can use package https://pub.dev/packages/keyboard_overlay
Step 1: Use with HandleFocusNodesOverlayMixin
Step 2: Use FocusNodeOverlay for focusNode
Step 3: Use GetFocusNodeOverlay and set _focusNodeOverlay = GetFocusNodeOverlay(
Step 4: TextField use TextField(focusNode: _focusNodeOverlay,
code snippet
class _MyHomePageState extends State<MyHomePage>
with HandleFocusNodesOverlayMixin {
FocusNodeOverlay _focusNodeOverlay;
#override
void initState() {
_focusNodeOverlay = GetFocusNodeOverlay(
child: TopKeyboardUtil(
Container(
color: Colors.white,
height: 45,
width: MediaQueryData.fromWindow(ui.window).size.width,
child: Row(
children: [
GestureDetector(
child: Icon(Icons.save),
onTap: () => print("click"),
),
...
Spacer(),
Container(
width: 60,
child: Center(
child: DoneButtonIos(
backgroundColor: Colors.white,
textColor: Colors.green,
label: 'Post',
onSubmitted: () {
print("submit");
},
platforms: ['android', 'ios'],
),
),
),
],
),
),
),
);
working demo
full code
import 'package:flutter/material.dart';
import 'package:keyboard_overlay/keyboard_overlay.dart';
import 'dart:ui' as ui;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with HandleFocusNodesOverlayMixin {
FocusNodeOverlay _focusNodeOverlay;
#override
void initState() {
_focusNodeOverlay = GetFocusNodeOverlay(
child: TopKeyboardUtil(
Container(
color: Colors.white,
height: 45,
width: MediaQueryData.fromWindow(ui.window).size.width,
child: Row(
children: [
GestureDetector(
child: Icon(Icons.save),
onTap: () => print("click"),
),
GestureDetector(
child: Icon(Icons.computer),
onTap: () => print("click"),
),
GestureDetector(
child: Icon(Icons.home),
onTap: () => print("click"),
),
Spacer(),
Container(
width: 60,
child: Center(
child: DoneButtonIos(
backgroundColor: Colors.white,
textColor: Colors.green,
label: 'Post',
onSubmitted: () {
print("submit");
},
platforms: ['android', 'ios'],
),
),
),
],
),
),
),
);
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
focusNode: _focusNodeOverlay,
style: TextStyle(color: Colors.grey),
decoration: InputDecoration(
labelText: 'Type Something',
labelStyle: TextStyle(color: Colors.black),
fillColor: Colors.orange,
hintStyle: TextStyle(
color: Colors.grey,
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.black, width: 1.0),
),
),
),
],
),
),
);
}
}
Yes there is a way around in the flutter to achieve this.
Create a widget of the toolbar you want to add.
Set it visible on input focus.
For reference I am sharing the code how I achieve that.
class InputDoneView extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
color: Style.lightGrey,
child: Align(
alignment: Alignment.topRight,
child: Padding(
padding: const EdgeInsets.only(top: 1.0, bottom: 1.0),
child: CupertinoButton(
padding: EdgeInsets.only(right: 24.0, top: 2.0, bottom: 2.0),
onPressed: () {
FocusScope.of(context).requestFocus(new FocusNode());
},
child: Text(
"Done",
style: TextStyle(color: Style.primaryColor,fontWeight: FontWeight.normal)
),
),
),
),
);
}
}
To call this in your main view when input field is focused in and out.
showOverlay(BuildContext context) {
if (overlayEntry != null) return;
OverlayState overlayState = Overlay.of(context);
overlayEntry = OverlayEntry(builder: (context) {
return Positioned(
bottom: MediaQuery.of(context).viewInsets.bottom, right: 0.0, left: 0.0, child: InputDoneView());
});
overlayState.insert(overlayEntry);
}
removeOverlay() {
if (overlayEntry != null) {
overlayEntry.remove();
overlayEntry = null;
}
}

Flutter: i want to save the image from camera or gallery to next page after cropping it here is my code

I want to save the image to the next page but after cropping the image it opens the next page but the image is not saved, here is my code it opens the camera take the pic or open gallery but after cropping it only take to the next page what should I do to save the cropped image to next page.I tried a method but it returns the image on UIpage.
import 'package:flutter/material.dart';
import 'package:fyp/ui.dart';
import 'package:fyp/Analyze.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Ui(),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:fyp/Analyze.dart';
import 'dart:io';
import 'package:image_picker/image_picker.dart';
import 'package:image_cropper/image_cropper.dart';
class Ui extends StatefulWidget {
#override
_UiState createState() => _UiState();
}
class _UiState extends State<Ui> {
String path;
File _selectedFile;
bool _inProcess1 = false;
#override
void initState() {
super.initState();
}
getImage(ImageSource source) async {
this.setState((){
_inProcess1 = true;
});
File image = await ImagePicker.pickImage(source: source);
if(image != null){
File cropped = await ImageCropper.cropImage(
sourcePath: image.path,
aspectRatio: CropAspectRatio(
ratioX: 1, ratioY: 1),
compressQuality: 100,
maxWidth: 700,
maxHeight: 700,
compressFormat: ImageCompressFormat.jpg,
androidUiSettings: AndroidUiSettings(
toolbarColor: Colors.deepOrange,
toolbarTitle: "RPS Cropper",
statusBarColor: Colors.deepOrange.shade900,
backgroundColor: Colors.white,
)
);
this.setState((){
_selectedFile = cropped;
return Analyze();
_inProcess1 = false;
});
} else {
this.setState((){
_inProcess1 = false;
});
}
}
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
elevation: 0,
toolbarHeight: 100,
leading:Padding(
padding: const EdgeInsets.fromLTRB(15, 20, 0, 0),
child: Column(
children: [
IconButton(icon: Icon(Icons.info_outlined, color: Colors.white,
size: 30,),
onPressed: ()=>null,),
Text(" Help",style: TextStyle(
color: Colors.white,
fontSize: 16,
), ),
],
),
),
actions: [
Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 20, 0),
child: Column(
children: [
IconButton(icon: Icon(Icons.upload_outlined, color: Colors.white,
size: 30,),
onPressed: ()
{ getImage(ImageSource.gallery); }
),
Text("Upload",style: TextStyle(
color: Colors.white,
fontSize: 16,
), ),
],
),
)
],
),
backgroundColor: Colors.blue,
body: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(0, 90, 0, 60),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Stack(
alignment: Alignment.center,
children: [
Opacity(
opacity:0.6,
child: CircleAvatar( // use to create circle
backgroundColor: Colors.white,
radius: 80,
),
),
Opacity(
opacity:0.5,
child: CircleAvatar(
backgroundColor: Colors.white,
radius: 120,
),
),
Opacity(
opacity:0.3,
child: CircleAvatar(
backgroundColor: Colors.white,
radius: 150,
),
),
Opacity(
opacity:0.7,
child: CircleAvatar(
backgroundColor: Colors.blue,
radius: 180,
),
),
IconButton(
iconSize: 80,
icon: Icon(Icons.camera_alt, color: Colors.white,),
onPressed: () {
getImage(ImageSource.camera);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Analyze(
),
),
);
},
),
],
),
],
),
),
Text("Tap to scan", style: TextStyle(
color: Colors.white,
fontSize: 20,
),),
SizedBox(
height: 20,
width: 150,
child: Divider(
color: Colors.white,
thickness: 3,
),
),
],
),
),
);
}
}
import 'package:flutter/material.dart';
import 'dart:io';
class Analyze extends StatefulWidget {
#override
_AnalyzeState createState() => _AnalyzeState();
}
class _AnalyzeState extends State<Analyze> {
File _selectedFile;
bool _inProcess = false;
#override
Widget build(BuildContext context) {
Widget getImageWidget(File selectedFile) {
if (_selectedFile != null) {
return Image.file(
_selectedFile,
width: 250,
height: 250,
fit: BoxFit.cover,
);
} else {
return Image.asset(
"assets/placeholder.jpg",
width: 250,
height: 250,
fit: BoxFit.cover,
);
}
}
(_inProcess)
? Container(
color: Colors.white,
height: MediaQuery.of(context).size.height * 0.95,
child: Center(
child: CircularProgressIndicator(),
),
)
: Center();
return SafeArea(
child: Scaffold(
body: Column(
children: [
getImageWidget(_selectedFile),
],
),
),
);
}

space in bottom navigation tab flutter

How can I add space equally where I use the dart logo as a floating action button.
I want to use this floating action button in the center so there will be the same space between the five of them. The other 4 icons are the bottom navigation bar item.
Can anyone please help me to find out the solution to this problem?
Here is my code:
import 'package:convex_bottom_bar/convex_bottom_bar.dart';
import 'package:eye_buddy/screen/homepage/pages/profile.dart';
import 'package:eye_buddy/screen/homepage/pages/settings.dart';
import 'package:flutter/material.dart';
import 'chat.dart';
import 'dashboard.dart';
import 'package:eye_buddy/util/colorconfig.dart';
class Home extends StatefulWidget {
#override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
int currentTab = 0; // to keep track of active tab index
final List<Widget> screens = [
Dashboard(),
Chat(),
Profile(),
Settings(),
]; // to store nested tabs
final PageStorageBucket bucket = PageStorageBucket();
Widget currentScreen = Dashboard(); // Our first view in viewport
#override
Widget build(BuildContext context) {
return Scaffold(
body: PageStorage(
child: currentScreen,
bucket: bucket,
),
floatingActionButton: GestureDetector(
onTap: () {
// Do Something
},
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/icon/eye.png'),
),
// borderRadius: BorderRadius.circular(0.50),
),
width: 110,
height: 94.68,
),
),
// FloatingActionButton(
// elevation: 0.0,
// child: Image.asset("assets/icon/eye.png"),
// backgroundColor: Colors.transparent,
// onPressed: () {},
// ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: ConvexAppBar(
backgroundColor: colorFromHex('#181D3D'),
style: TabStyle.react,
items: [
TabItem(icon: Icons.search),
TabItem(icon: Icons.bubble_chart),
TabItem(icon: Icons.assessment),
TabItem(icon: Icons.baby_changing_station),
],
initialActiveIndex: 1 /*optional*/,
onTap: (int i) => print('click index=$i'),
),
);
}
}
Try padding your dart logo :
Container(
padding: EdgeInsets.fromLTRB(16, 16, 16, 16),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/icon/eye.png'),
),
// borderRadius: BorderRadius.circular(0.50),
),
If till not works, then :
return BottomAppBar(
color: Colors.white,
child: Container(
height: 64,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [--your nav icons---],
),
),
shape: CircularNotchedRectangle(),
clipBehavior: Clip.antiAlias,
notchMargin: 5.0,
);

How to append Slider under the text within button when i press the raised Button?

Immediately after my app start it will show a button.
As soon as this button is pressed I want to build a slider within the same button to control the volume for this sound.
All I need is to make this slider appear and not the mechanics to control the volume.
what i want to acheive is here..
my button code
void main() => runApp(Home());
class Home extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: "RelaX",
home: Container(
child: Scaffold(
appBar: AppBar(
elevation: 20.0,
backgroundColor: Color(0xFF001E3D),
title: Text(
'Relax',
style: GoogleFonts.raleway(
fontSize: 30.0,
color: Color(0xFF55b9f3),
),
),
centerTitle: true,
),
body: Column(
children: <Widget>[
RaisedButton(
child: Text("View Slider"),
onPressed: () => print("view slider")),
],
),
),
),
);
}
}
You may use the Visibility widget to set the visibility of the slider. Please see the code below. I'm using Container along with Inkwell to achieve the same effect as RaisedButton.
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double _currentSliderValue = 0;
bool _sliderVisible = false;
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Raised Button"),
),
body: Center(
child: ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(20),
),
child: Container(
decoration: BoxDecoration(
color: Colors.blue[200],
borderRadius: const BorderRadius.all(
Radius.circular(20),
),
),
child: Material(
elevation: 2,
child: InkWell(
onTap: () {
setState(() {
_sliderVisible = !_sliderVisible;
});
},
child: Container(
width: 125.0,
height: 125.0,
child: Column(
children: [
const SizedBox(
height: 15,
),
Icon(
Icons.nightlight_round,
color: Colors.indigo[900],
size: 48,
),
const SizedBox(
height: 5,
),
Visibility(
visible: _sliderVisible,
child: Slider(
value: _currentSliderValue,
min: 0,
max: 10,
onChanged: (double value) {
setState(() {
_currentSliderValue = value;
});
},
activeColor: Colors.indigo[900],
inactiveColor: Colors.indigo[900],
),
)
],
),
),
),
color: Colors.transparent,
),
),
),
),
);
}
}

How can I align the icon according to the percentage of the progress bar?

I am using the percent indicator library and I need the icon to be aligned according to the percentage of the progress bar.
You can copy paste run full code below
You can remove Wrap and provide width , height and value to ProgressBarView
and use Transform.rotate to rotate icon
code snippet
Container(width: 400, height: 40, child: ProgressBarView(value: .9,)),
Divider(),
Container(width: 300, height: 40, child: ProgressBarView(value: .7,)),
Divider(),
Container(width: 100, height: 40, child: ProgressBarView(value: .4,)),
...
class ProgressBarView extends StatelessWidget {
ProgressBarView({this.value});
...
return Container(
color: Color(0Xffe6e6e6),
padding: EdgeInsets.only(left: 2, right: 2),
child: Stack(fit: StackFit.loose, children: [
LinearProgressIndicator(
value: value,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
backgroundColor: Colors.grey,
minHeight: 40),
working demo
full code
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(width: 400, height: 40, child: ProgressBarView(value: .9,)),
Divider(),
Container(width: 300, height: 40, child: ProgressBarView(value: .7,)),
Divider(),
Container(width: 100, height: 40, child: ProgressBarView(value: .4,)),
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
class ProgressBarView extends StatelessWidget {
ProgressBarView({this.value});
final value;
final _iconSize = 30;
#override
Widget build(BuildContext context) {
return Container(
color: Color(0Xffe6e6e6),
padding: EdgeInsets.only(left: 2, right: 2),
child: Stack(fit: StackFit.loose, children: [
LinearProgressIndicator(
value: value,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
backgroundColor: Colors.grey,
minHeight: 40),
LayoutBuilder(builder: (context, constrains) {
//5 is just the right padding
print(constrains.maxWidth);
var leftPadding = constrains.maxWidth * value - _iconSize;
var topPadding = (constrains.maxHeight - _iconSize) / 2;
return Padding(
padding: EdgeInsets.only(left: leftPadding, top: topPadding),
child: Transform.rotate(
angle: math.pi / 2,
child: Icon(Icons.airplanemode_active,
size: _iconSize.toDouble())),
);
})
]),
);
}
}
Not sure how are you placing the icon on top of the progress bar, but in case you are using a Stack this might help
Stack(
children: [
LinearProgressIndicator(
value: _value,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
backgroundColor: Colors.grey,
minHeight: 40
),
LayoutBuilder(
builder: (context, constrains) {
//5 is just the right padding
var leftPadding = constrains.maxWidth * _value - _iconSize - 5;
var topPadding = (constrains.maxHeight - _iconSize) / 2;
return Padding(
padding: EdgeInsets.only(left: leftPadding, top: topPadding),
child: Icon(
Icons.airplanemode_active,
size: _iconSize.toDouble()
),
);
}
)
]
),
Take a look at this codepen https://codepen.io/fcontreras-the-bashful/pen/GRZpRyg