How can create fully custom widgets using dart for flutter [closed] - flutter

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
How can create fully custom widgets using dart programming for flutter
without using any packages

You can create custom widgets like this-
class CustomWidget extends StatefulWidget {
String? selectedOption;
CustomWidget({ this.selectedOption});
#override
_CustomWidgetState createState() => _CustomWidgetState();
}
class _CustomWidgetState extends State<CustomWidget> {
String? _dropDownValue;
TextEditingController t1Controller = TextEditingController();
#override
Widget build(BuildContext context) {
double _width = MediaQuery.of(context).size.width;
return Material(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
child: Container(
width: _width,
height: 50,
child: Widget// Add here your widgets
),
);
}
}

Related

Custom circular progress indicator having multiple value [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 21 days ago.
Improve this question
I want to create a circle progress indicator like that:
How to do that?
You can use multi color like this in CircularProgressIndicator().
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mis/app_extensions.dart';
class LoadingIndicator extends StatefulWidget {
const LoadingIndicator({ Key? key,}) : super(key: key);
#override
State<LoadingIndicator> createState() =>_LoadingIndicatorState();
}
class _LoadingIndicatorState extends State<LoadingIndicator>
with SingleTickerProviderStateMixin {
late AnimationController animationController;
#override
void initState() {
animationController =
AnimationController(vsync: this, duration: Duration(seconds: 1));
animationController.repeat();
super.initState();
}
#override
void dispose() {
animationController.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: CircularProgressIndicator(
valueColor: animationController
.drive(ColorTween(begin: AppColors.blueTop, end: AppColors.red)),
),
);
}
}

enum variable has to be initialized in dart >>>>>>>>>>> Can you please tell me how to declare this variable [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
How can I declare the selectedGender variable? I'm having an initialize error.
The variable is inside a StatefullWidget.
enum Gendertype {male, female}
class _MyHomePageState extends State<MyHomePage> {
Gendertype selectedGender;
#override
Widget build(BuildContext context) {
return Column(
child: Expanded(
child: GestureDetector(
onTap: (){
setState(() {
selectedGender= Gendertype.male;
});
},
child: ReusedCard(
labledcolor: selectedGender==Gendertype.male?
inactivekcardcolor:activekcardcolor,
childCard: CardIcon(genderIcon: FontAwesomeIcons.mars,
labletype: "Male",
),
),
)
),
);
}
According to the null safety rules, you have these options:
Declare selectedGenderas a nullable variable:
Gendertype? selectedGender;
Define a first value to the variable:
Gendertype selectedGender = Gendertype.male

How to have stateless code inside a stateful widget in flutter? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I wanted to add a checkbox in my app, hence I tried converting the parent to a stateless widget, however, this caused all the formatting of the app to be disrupted. Is there a way to add stateless code inside a stateful widget?
According to your question, this might work
class Test1 extends StatefulWidget {
#override
_Test1State createState() => _Test1State();
}
class _Test1State extends State<Test1> {
#override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Test app',
home: new Scaffold(
appBar: new AppBar(
title: new Text("THis is stateful"),
),
body: new Test2(),
),
);
}
}
class Test2 extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text("This is stateless"),
),
);
}
}
Maybe use the parent widget as statefull and make a new stateless widget for your checkbox and form and use it inside your statefull widget by importing it.

How to fill the space between two text elements with dots in Flutter [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I am trying to show data like this:
Burger..........................$9.99
Steak and Potato...............$14.99
Mac and Cheese..................$6.99
How can I implement it in Flutter?
as an option
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) => MaterialApp(home: Home());
}
class Home extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Row(
children: [
Text('Burger'),
Expanded(child: Text('.' * 100, maxLines: 1)),
Text('\$9.99'),
],
),
);
}
}
I personally use fDottedLine package https://pub.dev/packages/fdottedline to draw a dotted line in any form.
: Row(
children: [
Text('Burger'),
FDottedLine(
color: Colors.black,
width: 160.0,
strokeWidth: 2.0,
dottedLength: 10.0,
space: 2.0,
),
Text('\$9.99'),
],
),
You have to give the dynamic widgth using MediaQuery

How to make a responsive play button in flutter? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I was able to make a play button but I could not able to make it responsive. If you can please tell me the code it would be helpful. Also I need to understand it as I am a beginner flutter user.
I think you should first learn about stateful widgets and basic flutter components first.
Introduction to widgets : https://flutter.dev/docs/development/ui/widgets-intro
Flutter Basic Widgets : https://flutter.dev/docs/development/ui/widgets
You can start from below code :
import 'package:flutter/material.dart';
class MusicPlayer extends StatefulWidget {
#override
_MusicPlayerState createState() => _MusicPlayerState();
}
class _MusicPlayerState extends State<MusicPlayer> {
var isPlaying = false;
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Music Player"),
),
body: Center(
child: IconButton(
icon: isPlaying
? Icon(
Icons.pause_circle_outline,
size: 40.0,
)
: Icon(Icons.play_circle_outline, size: 40.0),
onPressed: () {
setState(() {
isPlaying = !isPlaying;
});
}),
),
);
}
}
This will help you get started for your project.