首页 > 解决方案 > 小部件没有出现 - Flutter

问题描述

我正在使用AdvancedPageTurn来自advanced_pa ​​ge_turn 包的小部件。我将这个小部件包裹在 Scaffold body 属性中。该小部件完美地出现在模拟器上,但是当我在真实设备上启动应用程序时,该特定AdvancedPageTurn小部件根本没有出现。

可能是什么问题呢?

class Lyrics extends StatefulWidget {

 @override
 _LyricsState createState() => _LyricsState();
}

class _LyricsState extends State<Lyrics> {
 final _controller = GlobalKey<AdvancedPageTurnState>();


 @override
 Widget build(BuildContext context) {
   return Scaffold(
     appBar: AppBar(
       title: Text('App Title', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontFamily: 'oswald'),),
       centerTitle: true,
       flexibleSpace: Image(
         image: AssetImage('images/bg.jpg'),
         fit: BoxFit.cover,
       ),
     ),
     body: SafeArea(child: AdvancedPageTurn( // The Widget content is not appearing up at all but working fine on emulator 
       key: _controller,
       initialIndex: 0,
       children: [
           Container(
             decoration: BoxDecoration(
               image: DecorationImage(image: AssetImage('images/bg.jpg'), fit: BoxFit.cover),
             ),
             padding: EdgeInsets.all(25.0),
             child: Column(
               mainAxisAlignment: MainAxisAlignment.center,
               children: [
                 Text('Title 1', style: TextStyle(fontSize: 28.0, height: 1.8, fontWeight: FontWeight.bold, color: Colors.white, fontFamily: 'oswald'), textAlign: TextAlign.center,),
               ],
             ),
           ),
           Container(
           decoration: BoxDecoration(
             image: DecorationImage(image: AssetImage('images/bg.jpg'), fit: BoxFit.cover),
           ),
           padding: EdgeInsets.all(25.0),
           child: Column(
             mainAxisAlignment: MainAxisAlignment.center,
             children: [
                 Text('Title 2', style: TextStyle(fontSize: 28.0, height: 1.8, fontWeight: FontWeight.bold, color: Colors.white, fontFamily: 'oswald'), textAlign: TextAlign.center,),  
             ],
           ),
         ),

       ],
     ),
     ),
   );
 }
}

标签: flutterdartflutter-animationflutter-packages

解决方案


推荐阅读