Flutter
1main.dart---- 2 3import 'package:flutter/material.dart'; 4 5void main() { 6 runApp(MyApp()); 7} 8 9class MyApp extends StatelessWidget { 10 // This widget is the root of your application. 11 @override 12 Widget build(BuildContext context) { 13 return MaterialApp( 14 title: 'Flutter Demo', 15 theme: ThemeData( 16 // This is the theme of your application. 17 // 18 // Try running your application with "flutter run". You'll see the 19 // application has a blue toolbar. Then, without quitting the app, try 20 // changing the primarySwatch below to Colors.green and then invoke 21 // "hot reload" (press "r" in the console where you ran "flutter run", 22 // or simply save your changes to "hot reload" in a Flutter IDE). 23 // Notice that the counter didn't reset back to zero; the application 24 // is not restarted. 25 primarySwatch: Colors.blue, 26 // This makes the visual density adapt to the platform that you run 27 // the app on. For desktop platforms, the controls will be smaller and 28 // closer together (more dense) than on mobile platforms. 29 visualDensity: VisualDensity.adaptivePlatformDensity, 30 ), 31 home: XDPixel2(), 32 ); 33 } 34} 35 36class XDPixel2 extends StatefulWidget { 37 XDPixel2({Key key, this.title}) : super(key: key); 38 39 // This widget is the home page of your application. It is stateful, meaning 40 // that it has a State object (defined below) that contains fields that affect 41 // how it looks. 42 43 // This class is the configuration for the state. It holds the values (in this 44 // case the title) provided by the parent (in this case the App widget) and 45 // used by the build method of the State. Fields in a Widget subclass are 46 // always marked "final". 47 48 final String title; 49 50 @override 51 _MyHomePageState createState() => _MyHomePageState(); 52} 53 54class _MyHomePageState extends State<XDPixel2> { 55 int _counter = 0; 56 57 void _incrementCounter() { 58 setState(() { 59 // This call to setState tells the Flutter framework that something has 60 // changed in this State, which causes it to rerun the build method below 61 // so that the display can reflect the updated values. If we changed 62 // _counter without calling setState(), then the build method would not be 63 // called again, and so nothing would appear to happen. 64 _counter++; 65 }); 66 } 67 68 @override 69 Widget build(BuildContext context) { 70 // This method is rerun every time setState is called, for instance as done 71 // by the _incrementCounter method above. 72 // 73 // The Flutter framework has been optimized to make rerunning build methods 74 // fast, so that you can just rebuild anything that needs updating rather 75 // than having to individually change instances of widgets. 76 return Scaffold( 77 appBar: AppBar( 78 // Here we take the value from the MyHomePage object that was created by 79 // the App.build method, and use it to set our appbar title. 80 title: Text(widget.title), 81 ), 82 body: Center( 83 // Center is a layout widget. It takes a single child and positions it 84 // in the middle of the parent. 85 child: Column( 86 // Column is also a layout widget. It takes a list of children and 87 // arranges them vertically. By default, it sizes itself to fit its 88 // children horizontally, and tries to be as tall as its parent. 89 // 90 // Invoke "debug painting" (press "p" in the console, choose the 91 // "Toggle Debug Paint" action from the Flutter Inspector in Android 92 // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) 93 // to see the wireframe for each widget. 94 // 95 // Column has various properties to control how it sizes itself and 96 // how it positions its children. Here we use mainAxisAlignment to 97 // center the children vertically; the main axis here is the vertical 98 // axis because Columns are vertical (the cross axis would be 99 // horizontal). 100 mainAxisAlignment: MainAxisAlignment.center, 101 children: <Widget>[ 102 Text( 103 'You have pushed the button this many times:', 104 ), 105 Text( 106 '$_counter', 107 style: Theme.of(context).textTheme.headline4, 108 ), 109 ], 110 ), 111 ), 112 floatingActionButton: FloatingActionButton( 113 onPressed: _incrementCounter, 114 tooltip: 'Increment', 115 child: Icon(Icons.add), 116 ), // This trailing comma makes auto-formatting nicer for build methods. 117 ); 118 } 119}
Flutter
1 2XDPixel2.dart--- 3 4import 'package:adobe_xd/page_link.dart'; 5 6class XDPixel2 extends StatelessWidget { 7 XDPixel2({ 8 Key key, 9 }) : super(key: key); 10 @override 11 Widget build(BuildContext context) { 12 return MaterialApp( 13 home: Scaffold( 14 backgroundColor: const Color(0xffffffff), 15 body: Stack( 16 children: <Widget>[ 17 Transform.translate( 18 offset: Offset(20.0, 157.0), 19 child: 20 // Adobe XD layer: 'topimg' (shape) 21 Container( 22 width: 375.0, 23 height: 141.0, 24 decoration: BoxDecoration( 25 image: DecorationImage( 26 image: const AssetImage('assets/images/top.jpg'), 27 fit: BoxFit.fill, 28 ), 29 ), 30 ), 31 ), 32 Transform.translate( 33 offset: Offset(72.0, 374.0), 34 child: 35 // Adobe XD layer: '角丸長方形 5 のコピー 2' (shape) 36 Container( 37 width: 271.0, 38 height: 49.0, 39 decoration: BoxDecoration( 40 borderRadius: BorderRadius.circular(20.0), 41 color: const Color(0xffffffff), 42 border: Border.all(width: 1.0, color: const Color(0xff161616)), 43 ), 44 ), 45 ), 46 Transform.translate( 47 offset: Offset(88.4, 374.4), 48 child: PageLink( 49 links: [ 50 PageLinkInfo( 51 transition: LinkTransition.Fade, 52 ease: Curves.easeOut, 53 duration: 0.3, 54 pageBuilder: () => XDPixel21(), 55 ), 56 ], 57 child: SizedBox( 58 width: 234.0, 59 height: 49.0, 60 child: Text( 61 'ログイン', 62 style: TextStyle( 63 fontFamily: 'NotoSansJP', 64 fontSize: 29.170000076293945, 65 color: const Color(0xff161616), 66 fontWeight: FontWeight.w300, 67 height: 1.3712718510586308, 68 ), 69 textAlign: TextAlign.center, 70 ), 71 ), 72 ), 73 ), 74 Transform.translate( 75 offset: Offset(72.0, 482.0), 76 child: 77 // Adobe XD layer: '角丸長方形 5 のコピー 3' (shape) 78 Container( 79 width: 271.0, 80 height: 49.0, 81 decoration: BoxDecoration( 82 borderRadius: BorderRadius.circular(20.0), 83 color: const Color(0xffffffff), 84 border: Border.all(width: 1.0, color: const Color(0xff161616)), 85 ), 86 ), 87 ), 88 Transform.translate( 89 offset: Offset(72.4, 483.4), 90 child: SizedBox( 91 width: 270.0, 92 height: 48.0, 93 child: Text( 94 'ゲスト', 95 style: TextStyle( 96 fontFamily: 'NotoSansJP', 97 fontSize: 29.166669845581055, 98 color: const Color(0xff161616), 99 fontWeight: FontWeight.w300, 100 height: 1.3714284219547357, 101 ), 102 textAlign: TextAlign.center, 103 ), 104 ), 105 ), 106 ], 107 ), 108 ), 109 ); 110 } 111}
Flutter
1エラー 2 3A non-null String must be provided to a Text widget. 4'package:flutter/src/widgets/text.dart': 5Failed assertion: line 370 pos 10: 'data != null' 6The relevant error-causing widget was: 7 XDPixel2 file:///C:/flutter_kl/flutter_kl/lib/main.dart:29:13
デフォルトのmain.dartに変更を加えてアプリを起動させようとしたところ、
このようなエラーが出てしまいました。
このエラーが出るまでは起動できており、誤ってmain.dartを消してしまったので
新たな別プロジェクトを立ち上げ、そこからmain.dartを引っ張ってきたのですが適応がうまくいかず・・
どのように間違っているのでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。