Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] flutter – ListView builder

Posted on November 11, 2022 By

Solution 1 :

Take a look at shared preference

When you are adding the text to a list from the on saved method add the text to a List. Save this list in shared preferences. When you create the task card take it from shared preferences

Problem :

i want to make a to do list with input textField but when i refresh the page the list of tasks refreshs too so it become as default
to explain it i want to send a task by the text field and the task enter the list and after we will add a task to the bottom of the listView

class Tasks extends StatefulWidget {
  List<tasks> L = [];
  bool b = false;

  Tasks(this.L, this.b);

  @override
  State<Tasks> createState() => _TasksState();
}

class _TasksState extends State<Tasks> {
  final ctrl = TextEditingController();
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    ctrl.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Visibility(maintainInteractivity: true,maintainState: true,maintainSize: true,maintainAnimation: true,
          visible: this.widget.b,
          child: TextField(
            controller: ctrl,focusNode: FocusNode(descendantsAreFocusable: true),
            onSubmitted: (text) => {
              setState(() {
                String s = text;
                this.widget.L.add(tasks(text, []));
                ctrl.clear();
              })
            },
            decoration:
                InputDecoration(fillColor: Colors.white, hintText: "dafaf"),
            style: TextStyle(color: Colors.white, fontWeight: FontWeight.w400),
          )),
      Expanded(
          child: ListView.builder(
        itemCount: this.widget.L.length,
        itemBuilder: (BuildContext context, int index) {
          return Card(
            color: Colors.black,
            child: Column(
              children: [
                ListTile(
                    textColor: Colors.white,
                    iconColor: Colors.white,
                    title: Row(children: [
                      Checkbox(
                          value: false,
                          checkColor: Color.fromRGBO(85, 85, 85, 1),
                          tristate: false,
                          onChanged: (value) {}),
                      Text(this.widget.L[index].tite)
                    ])),
              ],
            ),
          );
        },
      ))
    ]);
  }
}
READ  [FIXED] java - Volley cant get error from server but shows me volley error listener why?
Powered by Inline Related Posts
Android Tags:android-studio, flutter, listview

Post navigation

Previous Post: [FIXED] android – W/Firestore: (24.1.2) [CustomClassMapper]: No setter/field for about found on class
Next Post: [FIXED] android – FusedLocationProviderClient and LocationCallback() object queries

Related Posts

[FIXED] How can I run codes once a day for fragment in android? Android
[FIXED] android – Cannot change height of BottomSheetBehavior dynamically Android
[FIXED] android – react-native How to open local file url using Linking? Android
[FIXED] android – OnClick in for-loop Android
[FIXED] accelerometer – rephrase definition for android orientation angle “roll” Android
[FIXED] java – How to identify a user on android? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme