When I try to set the border radius of the top two corners of my container that is nested inside a card, the whole content of the container goes disappears. Here is my code, if you uncomment the commented line your whole content inside the container will go away.
Widget build(BuildContext context) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
child: Container(
decoration: BoxDecoration(
border: new Border(
top: BorderSide(
color: Theme.of(context).primaryColor,
width: 3.0,
)), …Run Code Online (Sandbox Code Playgroud) 我是扑的新手。我正在尝试将 bottomappbar 小部件与主屏幕分开。问题是,我需要将索引发送回主屏幕文件,以便我可以切换屏幕主体。我最近一直在学习 BloC,但我认为这对于这种情况来说有点矫枉过正,即使我将在应用程序的其他部分使用它(希望这是正确的假设)。那么,如何将索引发送给父级?
家长
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _selectedIndex = 0;
final _bottomNavigationPages = [
Screen1(),
Screen2(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
iconTheme: IconThemeData(
color: Colors.blueGrey,
),
title:
Text('xxx', style: new TextStyle(fontWeight: FontWeight.w400)),
),
body: _bottomNavigationPages[_selectedIndex],
bottomNavigationBar: HomeBottomAppBar(),
);
}
}
Run Code Online (Sandbox Code Playgroud)
孩子
class HomeBottomAppBar extends StatefulWidget {
@override
_HomeBottomAppBarState createState() => _HomeBottomAppBarState();
}
class _HomeBottomAppBarState extends State<HomeBottomAppBar> {
int _selectedIndex = …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的颤振主题上使用自定义颜色,如下所示:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Onelog',
theme: ThemeData(
primarySwatch: MyColors.navy,
primaryTextTheme: TextTheme(title: TextStyle(color: Colors.black)),
),
//Code...
}
}
class MyColors {
static const Color navy = const Color(0xFF162A49);
}
Run Code Online (Sandbox Code Playgroud)
但这说明 Color 不是 Material color 的子类型