A physics textbook that I use mentions that "If a physical quantity has magnitude as well as direction but doesn't add up according to the triangle rule, it will not be called a vector quantity". The paragraph further explains that electric current is not a vector quantity because there is no meaning of triangle law there. While I understand why electric current is a scalar quantity, I am unable to comprehend how definite the rule is. For all I think, in the case of a right angled triangle, the rule is just calculating the hypotenuse (resultant vector). In dimensions two and above, it would make complete sense. However, in one dimension there isn't any angle involved and each point depends on only one real number. The two directions: left and right can be dealt with two sets of real numbers, i.e., negative and positive.
I want to know why vectors in one dimension can't be written as scalars. Why they must be written in the form of $x\hat{\imath}+0\hat {\jmath}+0\hat k$ when they can be mentioned simply as the scalar number on the $x$ axis.
This is one of those things that is always confusing, and you will find lots of examples where the way people refer to certain objects is ambiguous, particularly so in Algebra and its sub fields.
A vector is a member of a vector space over a field (numbers, things you can multiply vectors by which also have an inverse, apart from the zero element). This is essentially an abstract construction meant to formalize a notion of adding, subtracting, scaling them up or down, in a way that mimics displacement or position vectors in analytical geometry, the little arrows that you are introduced to as vectors. The "triangle law" which your textbook refers to is the addition rule for these kinds of vectors, and it says that the vector sum of two displacement vectors is the hypothenuse composed of "following one vector, then the other". But this of course only works when you can visualize your vectors in some cartesian space and its a bit ambiguous seeing as triangles only exist from dimension two onward.
This is not the right answer; a scalar is not something which doesn't follow the "triangle law". A scalar is a member of the field over which you have constructed your vector space. So the distinction of scalars and vectors is somewhat arbitrary; it depend on what you decided to call your vector space, and over which field you've decided to construct it on. For example, in highschool electromagnetism, you construct a three-dimensional cartesian vector space over the reals; this means that you want your position, velocity, acceleration vectors to be able to be multiplied by real numbers. So in this context we see that electric current is not a vector, seeing as it is a real number and we have decided to construct a vector space over the reals; so $I$ is a scalar in this theory, in this context; or rather, you've decided to model it as a scalar, as the rate of passage of charge by a certain area over a certain time.
But of course nothing stops you from constructing a vector space of real numbers over themselves; in this context, you could call $I$ a vector, seeing as for all intents and purposes it belongs to a vector space. This would just be another way to model the problem, to formulate it.
So which is it, scalar or vector? This isn't the right question. What you want to ask is, what better suits the system I'm studying? To build a displacement vector space over the reals and call $I$ a scalar or to build a vector space with the reals over themselves and call $I$ a vector? And you will most likely find that the first one is better, in the context you're studying. But I stress this, it is a matter of context. In higher level electromagnetism, the electric current is modeled as a three dimensional kind displacement vector, by following the paths of charges and seeing how fast they cross a certain area (and these charges follow three dimensional paths, so).
In conclusion, how do you know what is a scalar or a vector? Does it have a meaningful way of multiplying the things you decided were vectors, for example, velocity, position? Then those are scalars. But as you can see, it is mostly a matter of subtext.