import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'Classes.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
enum MaleFem {
Macho,
Hembra
}
int mcol = 0;
int fcol = 0;
const barcol = 80.0;
const col = 0xFF1d1E33;
const inctiv = 0xFFFFFF;
void main() => runApp(BMICalculator());
class BMICalculator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Calculadora del indice de masa corporal",
debugShowCheckedModeBanner: false,
theme: ThemeData.dark().copyWith(
appBarTheme: AppBarTheme(
backgroundColor: Color(0xff0a0e21),),
scaffoldBackgroundColor: Color(0xff0a0e21),
),
home: InputPage(),
);
}
}
class InputPage extends StatefulWidget {
@override
_InputPageState createState() => _InputPageState();
}
class _InputPageState extends State<InputPage> {
void changecolor(int g,m) {
g = g==1? col : inctiv;
m = g;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Center(child: Text('Indice de Masa Corporal')),
),
body: SafeArea(
child: Column(
children: <Widget> [
Row(
children: <Widget> [
// Macho
Expanded(child:
GestureDetector(
onTap: () {
setState(() {
changecolor(1,mcol);
});
},
child: MyCont(coloro: Color(mcol), ikono:IconandText(symbol: FontAwesomeIcons.mars, textu: 'Hombre'))),
),
// Hembra
Expanded(child: GestureDetector(
onTap: () {
setState(() {
changecolor(1,fcol);
});
},
child: MyCont(coloro: Color(fcol), ikono:IconandText(symbol: FontAwesomeIcons.venus, textu: 'Mujer'))),
),
],),
Expanded(
child: Row(
children: <Widget> [
MyCont(coloro: Color(col),)
]
),
),
Expanded(
child: Row(
children: <Widget> [
MyCont(coloro: Color(col)),
MyCont(coloro: Color(col))
] ),
),
Container(
color: Colors.pinkAccent,
margin: EdgeInsets.only(top: 10),
width: double.infinity,
height: barcol,
),
],
),
));
}
}
小部件库捕获到异常
应用父数据时引发了以下Assert:
ParentDataWidget的使用不正确。
ParentDataWidget Expanded(flex:1)希望将FlexParentData类型的ParentData应用于RenderObject,该RenderObject已设置为接受不兼容的ParentData类型的ParentData。
有谁能解释一下哪个是扩展的,哪个是不正确的?
附言:
是的,我知道布尔逻辑有一些错误,因为按钮的颜色男性和女性没有改变。
1条答案
按热度按时间camsedfj1#
Color
应使用8位十六进制整数示例化(例如0xFFFFFFFF
)const inctiv =0xFFFFFFFF;