title: How can I import other dart file to stateful widget in flutter?
body: <p>I'm new to flutter and trying to learn it.</p>
  <p>I have main.dart in lib, HomePage.dart in lib&gt;ui&gt;screens, and Widgets.dart in lib&gt;ui&gt;widgets.
  I imported the HomePage.dart to main.dart, and what I want is importing Widgets.dart to HomePage.dart.</p>
  <p>HomePage.dart contained stateful widget, and Widgets.dart contained some widgets and a stateful class.</p>
  <p>Below is the part of code.</p>
  <p>///main.dart///</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'ui/screens/HomePage.dart';
  import 'ui/screens/AnalysisPage.dart';
  
  void main(){
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'covid-19',
        initialRoute: '/',
        routes: {
          '/': (context) =&gt; HomePage(),
          '/analysis': (context) =&gt; AnalysisPage(),
          //'/news': (context) =&gt; NewsPage(),
          //'/more': (context) =&gt; MorePage(),
        },
        //home: HomePage(),
      );
    }
  }
  
  </code></pre>
  <p>///HomePage.dart///</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter/services.dart' show rootBundle;
  import 'package:covid_app/ui/widgets/Widgets.dart';
  
  
  class HomePage extends StatefulWidget {
    @override
    _HomePageState createState() =&gt; _HomePageState();
  }
  
  class _HomePageState extends State&lt;HomePage&gt; {
    String data = '';
  
    fetchFileData() async {
      String responseText;
      responseText = await rootBundle.loadString('lib/assets/number.txt');
  
      setState(() {
        data = responseText;
      });
    }
  
    @override
    void initState() {
      fetchFileData();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context){
  
      final Size size= MediaQuery.of(context).size;
      List&lt;String&gt; number = data.split(' ');
  
      return Scaffold(...)
  </code></pre>
  <p>///Widgets.dart///</p>
  <pre><code>import 'package:flutter/material.dart';
  
  Widget _drawer(BuildContext context){
    return Drawer(...)
  
  //More widgets in this file, but I'll skip it.
  
  class ClassificationCircle extends StatefulWidget {
  
    @override
    _ClassificationCircleState createState() =&gt; _ClassificationCircleState();
  }
  
  class _ClassificationCircleState extends State&lt;ClassificationCircle&gt; {
    @override
    Widget build(BuildContext context) {
      return Scaffold(...)
  </code></pre>
  <p>Thank you for reading, and I'll wait for your advice!</p>
  <p><a href="https://i.stack.imgur.com/pvP2a.png" rel="nofollow noreferrer">file structure !click me!</a></p>