Click here to Skip to main content
15,887,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, i get the following error message:

data != null
"A non-null String must be provided to a Text widget."

I dont know why i get this error message, please help me...

Dart
<pre>import 'package:flutter/material.dart';

class UserHome extends StatefulWidget {
  final String title;

  UserHome({Key key, this.title}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();

}



class _MyHomePageState extends State<UserHome> {
  int _selectedDestination = 0;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final textTheme = theme.textTheme;

    return MaterialApp(
      home: Scaffold(
      body: Row(
        children: [
          Drawer(
            child: ListView(
              // Important: Remove any padding from the ListView.
              padding: EdgeInsets.zero,
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Text(
                    'Header',
                    style: textTheme.headline6,
                  ),
                ),
                Divider(
                  height: 1,
                  thickness: 1,
                ),
                ListTile(
                  leading: Icon(Icons.favorite),
                  title: Text('Item 1'),
                  selected: _selectedDestination == 0,
                  onTap: () => selectDestination(0),
                ),
                ListTile(
                  leading: Icon(Icons.delete),
                  title: Text('Item 2'),
                  selected: _selectedDestination == 1,
                  onTap: () => selectDestination(1),
                ),
                ListTile(
                  leading: Icon(Icons.label),
                  title: Text('Item 3'),
                  selected: _selectedDestination == 2,
                  onTap: () => selectDestination(2),
                ),
                Divider(
                  height: 1,
                  thickness: 1,
                ),
                Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Text(
                    'Label',
                  ),
                ),
                ListTile(
                  leading: Icon(Icons.bookmark),
                  title: Text('Item A'),
                  selected: _selectedDestination == 3,
                  onTap: () => selectDestination(3),
                ),
              ],
            ),
          ),
          VerticalDivider(
            width: 1,
            thickness: 1,
          ),
          Expanded(
            child: Scaffold(
              appBar: AppBar(
                title: Text(widget.title),
              ),
              body: GridView.count(
                crossAxisCount: 2,
                crossAxisSpacing: 20,
                mainAxisSpacing: 20,
                padding: EdgeInsets.all(20),
                childAspectRatio: 3 / 2,
                children: [
                  Image.asset('assets/nav-drawer-1.svg'),
                  Image.asset('assets/nav-drawer-2.svg'),
                  Image.asset('assets/nav-drawer-3.svg'),
                  Image.asset('assets/nav-drawer-4.svg'),
                ],
              ),
            ),
          ),
        ],
      ),
    ),
    );
  }

  void selectDestination(int index) {
    setState(() {
      _selectedDestination = index;
    });
  }
}


What I have tried:

I searched for this topic in the internet and found out that a variable is empty but i dont know which of these i using it is.
Posted
Updated 4-Feb-21 5:49am

1 solution

I guess is this
title: Text(widget.title),


Try replace it with other String, see is this issue still persist?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900